"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
config: support hyphen in remote name from environment variable
albertony59c74ea1b839
diff --git a/cmdtest/environment_test.go b/cmdtest/environment_test.goindex 14538522e..2124dc31c 100644--- a/cmdtest/environment_test.go+++ b/cmdtest/environment_test.go@@ -78,6 +78,59 @@ func TestEnvironmentVariables(t *testing.T) {assert.Contains(t, out, "RCLONE_STATS=")}+ // Backend flags and remote name+ // - The listremotes command includes names from environment variables,+ // the part between "RCLONE_CONFIG_" and "_TYPE", converted to lowercase.+ // - When using using a remote created from env, e.g. with lsd command,+ // the name is case insensitive in contrast to remotes in config file+ // (fs.ConfigToEnv converts to uppercase before checking environment).+ // - Previously using a remote created from env, e.g. with lsd command,+ // would not be possible for remotes with '-' in names, and remote names+ // with '_' could be referred to with both '-' and '_', because any '-'+ // were replaced with '_' before lookup.+ // ===================================++ env = "RCLONE_CONFIG_MY-LOCAL_TYPE=local"+ out, err = rcloneEnv(env, "listremotes")+ if assert.NoError(t, err) {+ assert.Contains(t, out, "my-local:")+ }+ out, err = rcloneEnv(env, "lsl", "my-local:"+testFolder)+ if assert.NoError(t, err) {+ assert.Contains(t, out, "rclone.config")+ assert.Contains(t, out, "file1.txt")+ assert.Contains(t, out, "fileA1.txt")+ assert.Contains(t, out, "fileAA1.txt")+ }+ out, err = rcloneEnv(env, "lsl", "mY-LoCaL:"+testFolder)+ if assert.NoError(t, err) {+ assert.Contains(t, out, "rclone.config")+ assert.Contains(t, out, "file1.txt")+ assert.Contains(t, out, "fileA1.txt")+ assert.Contains(t, out, "fileAA1.txt")+ }+ out, err = rcloneEnv(env, "lsl", "my_local:"+testFolder)+ if assert.Error(t, err) {+ assert.Contains(t, out, "Failed to create file system")+ }++ env = "RCLONE_CONFIG_MY_LOCAL_TYPE=local"+ out, err = rcloneEnv(env, "listremotes")+ if assert.NoError(t, err) {+ assert.Contains(t, out, "my_local:")+ }+ out, err = rcloneEnv(env, "lsl", "my_local:"+testFolder)+ if assert.NoError(t, err) {+ assert.Contains(t, out, "rclone.config")+ assert.Contains(t, out, "file1.txt")+ assert.Contains(t, out, "fileA1.txt")+ assert.Contains(t, out, "fileAA1.txt")+ }+ out, err = rcloneEnv(env, "lsl", "my-local:"+testFolder)+ if assert.Error(t, err) {+ assert.Contains(t, out, "Failed to create file system")+ }+// Backend flags and option precedence// ===================================@@ -86,7 +139,6 @@ func TestEnvironmentVariables(t *testing.T) {// and skip_links=false on all levels with lower precedence//// Reference: https://rclone.org/docs/#precedence-// Create a symlink in test dataerr = os.Symlink(testdataPath+"/folderA", testdataPath+"/symlinkA")if runtime.GOOS == "windows" {diff --git a/fs/config.go b/fs/config.goindex e5fabb6ad..3a4de7717 100644--- a/fs/config.go+++ b/fs/config.go@@ -237,11 +237,11 @@ func AddConfig(ctx context.Context) (context.Context, *ConfigInfo) {return newCtx, cCopy}-// ConfigToEnv converts a config section and name, e.g. ("myremote",+// ConfigToEnv converts a config section and name, e.g. ("my-remote",// "ignore-size") into an environment name-// "RCLONE_CONFIG_MYREMOTE_IGNORE_SIZE"+// "RCLONE_CONFIG_MY-REMOTE_IGNORE_SIZE"func ConfigToEnv(section, name string) string {- return "RCLONE_CONFIG_" + strings.ToUpper(strings.Replace(section+"_"+name, "-", "_", -1))+ return "RCLONE_CONFIG_" + strings.ToUpper(section+"_"+strings.Replace(name, "-", "_", -1))}// OptionToEnv converts an option name, e.g. "ignore-size" into an