1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

fs: Pin created backends until parents are finalized

This attempts to solve the backend lifecycle problem by

- Pinning backends mentioned on the command line into the cache
  indefinitely

- Unpinning backends when the containing structure (VFS, wrapping
  backend) is destroyed

See: https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834
This commit is contained in:
Nick Craig-Wood
2020-08-31 17:46:58 +01:00
parent 0d066bdf46
commit 70c8566cb8
7 changed files with 23 additions and 5 deletions

View File

@@ -234,8 +234,8 @@ func New(f fs.Fs, opt *vfscommon.Options) *VFS {
// Pin the Fs into the cache so that when we use cache.NewFs
// with the same remote string we get this one. The Pin is
// removed by Shutdown
cache.Pin(f)
// removed when the vfs is finalized
cache.PinUntilFinalized(f, vfs)
return vfs
}
@@ -293,9 +293,6 @@ func (vfs *VFS) Shutdown() {
return
}
// Unpin the Fs from the cache
cache.Unpin(vfs.f)
// Remove from active cache
activeMu.Lock()
configName := fs.ConfigString(vfs.f)