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: fix ChangeNotify for new or changed folders

Fabian Möller98bf65c43b74
diff --git a/vfs/vfs.go b/vfs/vfs.go
index 053363483..3813a0817 100644
--- a/vfs/vfs.go
+++ b/vfs/vfs.go
@@ -224,7 +224,7 @@ func New(f fs.Fs, opt *Options) *VFS {
// Start polling if required
if vfs.Opt.PollInterval > 0 {
if do := vfs.f.Features().ChangeNotify; do != nil {
- do(vfs.root.ForgetPath, vfs.Opt.PollInterval)
+ do(vfs.notifyFunc, vfs.Opt.PollInterval)
} else {
fs.Infof(f, "poll-interval is not supported by this remote")
}
@@ -495,3 +495,13 @@ func (vfs *VFS) Statfs() (total, used, free int64) {
}
return
}
+
+// notifyFunc removes the last path segement for directories and calls ForgetPath with the result.
+//
+// This ensures that new or renamed directories appear in their parent.
+func (vfs *VFS) notifyFunc(relativePath string, entryType fs.EntryType) {
+ if entryType == fs.EntryDirectory {
+ relativePath = path.Dir(relativePath)
+ }
+ vfs.root.ForgetPath(relativePath, entryType)
+}