1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-16 08:13:29 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Nick Craig-Wood
be2c44f5af rc: config/unlock: rename parameter to configPassword accept old as well
We accidentally added a non `camelCase` parameter to the rc
(`config_password`)- this fixes it (to `configPassword`) but accepts
the old name too as it has been in a release.
2025-11-20 16:09:25 +00:00
Nick Craig-Wood
1db0f51be4 rc: correct names of parameters in job/list output
These were accidentally committed as snake_case whereas we use
camelCase elsewhere.

This corrects the issue before the first release in v1.72.0
2025-11-20 15:47:51 +00:00
4 changed files with 29 additions and 12 deletions

View File

@@ -20,7 +20,7 @@ Unlocks the config file if it is locked.
Parameters: 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 A good idea is to disable AskPassword before making this call
`, `,
@@ -30,10 +30,14 @@ A good idea is to disable AskPassword before making this call
// Unlock the config file // Unlock the config file
// A good idea is to disable AskPassword before making this call // A good idea is to disable AskPassword before making this call
func rcConfigPassword(ctx context.Context, in rc.Params) (out rc.Params, err error) { 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 { if err != nil {
var err2 error
configPass, err2 = in.GetString("config_password") // backwards compat
if err2 != nil {
return nil, err return nil, err
} }
}
if SetConfigPassword(configPass) != nil { if SetConfigPassword(configPass) != nil {
return nil, errors.New("failed to set config password") return nil, errors.New("failed to set config password")
} }

View File

@@ -215,13 +215,26 @@ func TestRcPaths(t *testing.T) {
func TestRcConfigUnlock(t *testing.T) { func TestRcConfigUnlock(t *testing.T) {
call := rc.Calls.Get("config/unlock") call := rc.Calls.Get("config/unlock")
assert.NotNil(t, call) assert.NotNil(t, call)
in := rc.Params{ in := rc.Params{
"config_password": "test", "configPassword": "test",
} }
out, err := call.Fn(context.Background(), in) out, err := call.Fn(context.Background(), in)
require.NoError(t, err) require.NoError(t, err)
assert.Nil(t, err)
assert.Nil(t, out) assert.Nil(t, out)
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)
} }

View File

@@ -425,8 +425,8 @@ Results:
- executeId - string id of rclone executing (change after restart) - executeId - string id of rclone executing (change after restart)
- jobids - array of integer job ids (starting at 1 on each restart) - jobids - array of integer job ids (starting at 1 on each restart)
- running_ids - array of integer job ids that are running - runningIds - array of integer job ids that are running
- finished_ids - array of integer job ids that are finished - finishedIds - array of integer job ids that are finished
`, `,
}) })
} }
@@ -436,8 +436,8 @@ func rcJobList(ctx context.Context, in rc.Params) (out rc.Params, err error) {
out = make(rc.Params) out = make(rc.Params)
out["jobids"] = running.IDs() out["jobids"] = running.IDs()
runningIDs, finishedIDs := running.Stats() runningIDs, finishedIDs := running.Stats()
out["running_ids"] = runningIDs out["runningIds"] = runningIDs
out["finished_ids"] = finishedIDs out["finishedIds"] = finishedIDs
out["executeId"] = executeID out["executeId"] = executeID
return out, nil return out, nil
} }

View File

@@ -378,8 +378,8 @@ func TestRcJobList(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, out1) require.NotNil(t, out1)
assert.Equal(t, []int64{1}, out1["jobids"], "should have job listed") assert.Equal(t, []int64{1}, out1["jobids"], "should have job listed")
assert.Equal(t, []int64{1}, out1["running_ids"], "should have running job") assert.Equal(t, []int64{1}, out1["runningIds"], "should have running job")
assert.Equal(t, []int64{}, out1["finished_ids"], "should not have finished job") assert.Equal(t, []int64{}, out1["finishedIds"], "should not have finished job")
_, _, err = NewJob(ctx, longFn, rc.Params{"_async": true}) _, _, err = NewJob(ctx, longFn, rc.Params{"_async": true})
assert.NoError(t, err) assert.NoError(t, err)