mirror of
https://github.com/rclone/rclone.git
synced 2025-08-18 17:38:52 +02:00
vfs: add --vfs-refresh flag to read all the directories on start
Refreshes the directory listing recursively at VFS start time.
This commit is contained in:
committed by
Nick Craig-Wood
parent
a752563842
commit
3337fe31c7
14
vfs/vfs.go
14
vfs/vfs.go
@@ -232,12 +232,26 @@ func New(f fs.Fs, opt *vfscommon.Options) *VFS {
|
||||
// removed when the vfs is finalized
|
||||
cache.PinUntilFinalized(f, vfs)
|
||||
|
||||
// Refresh the dircache if required
|
||||
if vfs.Opt.Refresh {
|
||||
go vfs.refresh()
|
||||
}
|
||||
|
||||
// This can take some time so do it after the Pin
|
||||
vfs.SetCacheMode(vfs.Opt.CacheMode)
|
||||
|
||||
return vfs
|
||||
}
|
||||
|
||||
// refresh the directory cache for all directories
|
||||
func (vfs *VFS) refresh() {
|
||||
fs.Debugf(vfs.f, "Refreshing VFS directory cache")
|
||||
err := vfs.root.readDirTree()
|
||||
if err != nil {
|
||||
fs.Errorf(vfs.f, "Error refreshing VFS directory cache: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Stats returns info about the VFS
|
||||
func (vfs *VFS) Stats() (out rc.Params) {
|
||||
out = make(rc.Params)
|
||||
|
Reference in New Issue
Block a user