Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

vfs: shorten the locking window for vfs/refresh

Nick Craig-Wood1692c6bd0aa6
diff --git a/vfs/dir.go b/vfs/dir.go
index aa7567cc8..5aa450c4f 100644
--- a/vfs/dir.go
+++ b/vfs/dir.go
@@ -290,14 +290,17 @@ func (d *Dir) _readDirFromEntries(entries fs.DirEntries, dirTree walk.DirTree, w
// readDirTree forces a refresh of the complete directory tree
func (d *Dir) readDirTree() error {
d.mu.Lock()
- defer d.mu.Unlock()
+ f, path := d.f, d.path
+ d.mu.Unlock()
when := time.Now()
- d.read = time.Time{}
- fs.Debugf(d.path, "Reading directory tree")
- dt, err := walk.NewDirTree(d.f, d.path, false, -1)
+ fs.Debugf(path, "Reading directory tree")
+ dt, err := walk.NewDirTree(f, path, false, -1)
if err != nil {
return err
}
+ d.mu.Lock()
+ defer d.mu.Unlock()
+ d.read = time.Time{}
err = d._readDirFromDirTree(dt, when)
if err != nil {
return err