mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:41:44 +08:00
vfs: pin the Fs in use in the Fs cache
This means we can reliably look up the Fs from the cache when using `backend/command`.
This commit is contained in:
parent
4c98360356
commit
70db13e6e8
|
@ -34,6 +34,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
|
"github.com/rclone/rclone/fs/cache"
|
||||||
"github.com/rclone/rclone/fs/log"
|
"github.com/rclone/rclone/fs/log"
|
||||||
"github.com/rclone/rclone/vfs/vfscache"
|
"github.com/rclone/rclone/vfs/vfscache"
|
||||||
"github.com/rclone/rclone/vfs/vfscommon"
|
"github.com/rclone/rclone/vfs/vfscommon"
|
||||||
|
@ -204,6 +205,11 @@ func New(f fs.Fs, opt *vfscommon.Options) *VFS {
|
||||||
|
|
||||||
// add the remote control
|
// add the remote control
|
||||||
vfs.addRC()
|
vfs.addRC()
|
||||||
|
|
||||||
|
// 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)
|
||||||
return vfs
|
return vfs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +239,8 @@ func (vfs *VFS) SetCacheMode(cacheMode vfscommon.CacheMode) {
|
||||||
|
|
||||||
// Shutdown stops any background go-routines
|
// Shutdown stops any background go-routines
|
||||||
func (vfs *VFS) Shutdown() {
|
func (vfs *VFS) Shutdown() {
|
||||||
|
// Unpin the Fs from the cache
|
||||||
|
cache.Unpin(vfs.f)
|
||||||
if vfs.cancel != nil {
|
if vfs.cancel != nil {
|
||||||
vfs.cancel()
|
vfs.cancel()
|
||||||
vfs.cancel = nil
|
vfs.cancel = nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user