"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
s3: implement backend set command to update running config
Nick Craig-Wood2bcbed30bd07
diff --git a/backend/s3/s3.go b/backend/s3/s3.goindex 02fe34d5f..e9fbead06 100644--- a/backend/s3/s3.go+++ b/backend/s3/s3.go@@ -4504,6 +4504,26 @@ supplied.It may return "Enabled", "Suspended" or "Unversioned". Note that once versioninghas been enabled the status can't be set back to "Unversioned".`,+}, {+ Name: "set",+ Short: "Set command for updating the config parameters.",+ Long: `This set command can be used to update the config parameters+for a running s3 backend.++Usage Examples:++ rclone backend set s3: [-o opt_name=opt_value] [-o opt_name2=opt_value2]+ rclone rc backend/command command=set fs=s3: [-o opt_name=opt_value] [-o opt_name2=opt_value2]+ rclone rc backend/command command=set fs=s3: -o session_token=X -o access_key_id=X -o secret_access_key=X++The option keys are named as they are in the config file.++This rebuilds the connection to the s3 backend when it is called with+the new parameters. Only new parameters need be passed as the values+will default to those currently in use.++It doesn't return anything.+`,}}// Command the backend to run a named command@@ -4598,6 +4618,25 @@ func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[strreturn nil, f.CleanUpHidden(ctx)case "versioning":return f.setGetVersioning(ctx, arg...)+ case "set":+ newOpt := f.opt+ err := configstruct.Set(configmap.Simple(opt), &newOpt)+ if err != nil {+ return nil, fmt.Errorf("reading config: %w", err)+ }+ c, ses, err := s3Connection(f.ctx, &newOpt, f.srv)+ if err != nil {+ return nil, fmt.Errorf("updating session: %w", err)+ }+ f.c = c+ f.ses = ses+ f.opt = newOpt+ keys := []string{}+ for k := range opt {+ keys = append(keys, k)+ }+ fs.Logf(f, "Updated config values: %s", strings.Join(keys, ", "))+ return nil, nildefault:return nil, fs.ErrorCommandNotFound}