config: clear fs cache of stale entries when altering config - fixes #4811

Before this change if a config was altered via the rc then when a new
backend was created from that config, if there was a backend already
running from the old config in the cache then it would be used instead
of creating a new backend with the new config, thus leading to
confusion.

This change flushes the fs cache of any backends based off a config
when that config is changed is over the rc.
This commit is contained in:
Nick Craig-Wood 2020-11-30 11:53:11 +00:00
parent a10fbf16ea
commit 3b21857097
1 changed files with 2 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import (
"github.com/pkg/errors"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/cache"
"github.com/rclone/rclone/fs/config/obscure"
"github.com/rclone/rclone/fs/fspath"
"github.com/rclone/rclone/fs/rc"
@ -316,6 +317,7 @@ func UpdateRemote(ctx context.Context, name string, keyValues rc.Params, doObscu
}
RemoteConfig(ctx, name)
SaveConfig()
cache.ClearConfig(name) // remove any remotes based on this config from the cache
return nil
}