Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

rc: config/unlock: rename parameter to `configPassword` accept old as well

Nick Craig-Wood6d4c625bfb87
diff --git a/fs/config/rc.go b/fs/config/rc.go
index 62484541c..78c33ee5d 100644
--- a/fs/config/rc.go
+++ b/fs/config/rc.go
@@ -20,7 +20,7 @@ Unlocks the config file if it is locked.
Parameters:
-- 'config_password' - password to unlock the config file
+- 'configPassword' - password to unlock the config file
A good idea is to disable AskPassword before making this call
`,
@@ -30,9 +30,13 @@ A good idea is to disable AskPassword before making this call
// Unlock the config file
// A good idea is to disable AskPassword before making this call
func rcConfigPassword(ctx context.Context, in rc.Params) (out rc.Params, err error) {
- configPass, err := in.GetString("config_password")
+ configPass, err := in.GetString("configPassword")
if err != nil {
- return nil, err
+ var err2 error
+ configPass, err2 = in.GetString("config_password") // backwards compat
+ if err2 != nil {
+ return nil, err
+ }
}
if SetConfigPassword(configPass) != nil {
return nil, errors.New("failed to set config password")
diff --git a/fs/config/rc_test.go b/fs/config/rc_test.go
index 682a8fe71..574246c2c 100644
--- a/fs/config/rc_test.go
+++ b/fs/config/rc_test.go
@@ -215,13 +215,26 @@ func TestRcPaths(t *testing.T) {
func TestRcConfigUnlock(t *testing.T) {
call := rc.Calls.Get("config/unlock")
assert.NotNil(t, call)
+
in := rc.Params{
- "config_password": "test",
+ "configPassword": "test",
}
out, err := call.Fn(context.Background(), in)
require.NoError(t, err)
+ assert.Nil(t, out)
- assert.Nil(t, err)
+ in = rc.Params{
+ "config_password": "test",
+ }
+ out, err = call.Fn(context.Background(), in)
+ require.NoError(t, err)
assert.Nil(t, out)
+ in = rc.Params{
+ "bad_config_password": "test",
+ }
+ out, err = call.Fn(context.Background(), in)
+ require.Error(t, err)
+ assert.ErrorContains(t, err, `Didn't find key "configPassword" in input`)
+ assert.Nil(t, out)
}