"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: fix directory locking caused by slow directory listings
Nick Craig-Woodddfde6814073
diff --git a/vfs/dir.go b/vfs/dir.goindex a6889eb4c..972f75b23 100644--- a/vfs/dir.go+++ b/vfs/dir.go@@ -29,12 +29,14 @@ type Dir struct {mu sync.RWMutex // protects the followingparent *Dir // parent, nil for rootpath string- modTime time.Timeentry fs.Directoryread time.Time // time directory entry last readitems map[string]Node // directory entries - can be empty but not nilvirtual map[string]vState // virtual directory entries - may be nilsys atomic.Value // user defined info to be attached here++ modTimeMu sync.Mutex // protects the following+ modTime time.Time}//go:generate stringer -type=vState@@ -270,11 +272,13 @@ func (d *Dir) _age(when time.Time) (age time.Duration, stale bool) {// reading everything againfunc (d *Dir) rename(newParent *Dir, fsDir fs.Directory) {d.ForgetAll()+ d.modTimeMu.Lock()+ d.modTime = fsDir.ModTime(context.TODO())+ d.modTimeMu.Unlock()d.mu.Lock()d.parent = newParentd.entry = fsDird.path = fsDir.Remote()- d.modTime = fsDir.ModTime(context.TODO())d.read = time.Time{}d.mu.Unlock()}@@ -550,8 +554,8 @@ func (d *Dir) isEmpty() (bool, error) {// ModTime returns the modification time of the directoryfunc (d *Dir) ModTime() time.Time {- d.mu.RLock()- defer d.mu.RUnlock()+ d.modTimeMu.Lock()+ defer d.modTimeMu.Unlock()// fs.Debugf(d.path, "Dir.ModTime %v", d.modTime)return d.modTime}@@ -566,9 +570,9 @@ func (d *Dir) SetModTime(modTime time.Time) error {if d.vfs.Opt.ReadOnly {return EROFS}- d.mu.Lock()+ d.modTimeMu.Lock()d.modTime = modTime- d.mu.Unlock()+ d.modTimeMu.Unlock()return nil}