mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 09:32:29 +08:00
vfs: fix vfs/refresh calls with fs= parameter
Before this change rclone gave an error when the fs parameter was provided. This change removes the fs parameter from the parameters once it has been read which avoids the error. See: https://forum.rclone.org/t/precaching-with-vfs-refresh-fails-with-an-error-when-having-multiple-cloud-drives/20267
This commit is contained in:
parent
6c70c42577
commit
43e0929339
|
@ -23,6 +23,8 @@ must be supplied.`
|
|||
//
|
||||
// If "fs" is not set and there is one and only one VFS in the active
|
||||
// cache then it returns it. This is for backwards compatibility.
|
||||
//
|
||||
// This deletes the "fs" parameter from in if it is valid
|
||||
func getVFS(in rc.Params) (vfs *VFS, err error) {
|
||||
fsString, err := in.GetString("fs")
|
||||
if rc.IsErrParamNotFound(err) {
|
||||
|
@ -46,6 +48,7 @@ func getVFS(in rc.Params) (vfs *VFS, err error) {
|
|||
} else if len(activeVFS) > 1 {
|
||||
return nil, errors.Errorf("more than one VFS active with name %q", fsString)
|
||||
}
|
||||
delete(in, "fs") // delete the fs parameter
|
||||
return activeVFS[0], nil
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ func TestRcGetVFS(t *testing.T) {
|
|||
assert.Contains(t, err.Error(), "more than one VFS active - need")
|
||||
assert.Nil(t, vfs)
|
||||
|
||||
inPresent = rc.Params{"fs": fs.ConfigString(r.Fremote)}
|
||||
vfs, err = getVFS(inPresent)
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "more than one VFS active with name")
|
||||
|
@ -67,7 +68,8 @@ func TestRcForget(t *testing.T) {
|
|||
r, vfs, cleanup, call := rcNewRun(t, "vfs/forget")
|
||||
defer cleanup()
|
||||
_, _ = r, vfs
|
||||
out, err := call.Fn(context.Background(), nil)
|
||||
in := rc.Params{"fs": fs.ConfigString(r.Fremote)}
|
||||
out, err := call.Fn(context.Background(), in)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, rc.Params{
|
||||
"forgotten": []string{},
|
||||
|
@ -79,7 +81,8 @@ func TestRcRefresh(t *testing.T) {
|
|||
r, vfs, cleanup, call := rcNewRun(t, "vfs/refresh")
|
||||
defer cleanup()
|
||||
_, _ = r, vfs
|
||||
out, err := call.Fn(context.Background(), nil)
|
||||
in := rc.Params{"fs": fs.ConfigString(r.Fremote)}
|
||||
out, err := call.Fn(context.Background(), in)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, rc.Params{
|
||||
"result": map[string]string{
|
||||
|
|
Loading…
Reference in New Issue
Block a user