"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
rc: add plugins support
Chaitanya4cf82118d914
diff --git a/fs/rc/plugins.go b/fs/rc/plugins.gonew file mode 100644index 000000000..e49f43e11--- /dev/null+++ b/fs/rc/plugins.go@@ -0,0 +1,127 @@+package rc++import (+ "context"+ "errors"+ "fmt"+)++type PackageJSON struct {+ Name string `json:"name"`+ Version string `json:"version"`+ Description string `json:"description"`+ Author string `json:"author"`+ Copyright string `json:"copyright"`+ License string `json:"license"`+ Private bool `json:"private"`+ Homepage string `json:"homepage"`+ Repository struct {+ Type string `json:"type"`+ URL string `json:"url"`+ } `json:"repository"`+ Bugs struct {+ URL string `json:"url"`+ } `json:"bugs"`+}++var loadedTestPlugins map[string]string++func init() {+ loadedTestPlugins = make(map[string]string)+}++func init() {+ Add(Call{+ Path: "pluginsctl/addTestPlugin",+ AuthRequired: true,+ Fn: rcAddPlugin,+ Title: "Show current mount points",+ Help: `This shows currently mounted points, which can be used for performing an unmount++This takes no parameters and returns++- mountPoints: list of current mount points++Eg++ rclone rc mount/listmounts+`,+ })+}++func rcAddPlugin(_ context.Context, in Params) (out Params, err error) {+ test, err := in.GetBool("test")+ if err != nil {+ return nil, err+ }+ name, err := in.GetString("name")+ if err != nil {+ return nil, err+ }++ url, err := in.GetString("loadUrl")+ if err != nil {+ return nil, err+ }+ if test {+ loadedTestPlugins[name] = url+ }+ return nil, nil+}++func init() {+ Add(Call{+ Path: "pluginsctl/listTestPlugins",+ AuthRequired: true,+ Fn: rcGetLoadedPlugins,+ Title: "Show current mount points",+ Help: `This shows currently mounted points, which can be used for performing an unmount++This takes no parameters and returns++- mountPoints: list of current mount points++Eg++ rclone rc mount/listmounts+`,+ })+}++func rcGetLoadedPlugins(_ context.Context, in Params) (out Params, err error) {+ return Params{+ "loadedTestPlugins": loadedTestPlugins,+ }, nil+}++func init() {+ Add(Call{+ Path: "pluginsctl/removeTestPlugin",+ AuthRequired: true,+ Fn: rcRemovePlugin,+ Title: "Show current mount points",+ Help: `This shows currently mounted points, which can be used for performing an unmount++This takes no parameters and returns++- mountPoints: list of current mount points++Eg++ rclone rc mount/listmounts+`,+ })+}++func rcRemovePlugin(_ context.Context, in Params) (out Params, err error) {+ name, err := in.GetString("name")+ if err != nil {+ return nil, err+ }+ _, ok := loadedTestPlugins[name]+ if ok {+ delete(loadedTestPlugins, name)+ return nil, nil+ }+ return nil, errors.New(fmt.Sprintf("plugin %s not loaded", name))+}