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

amazonclouddrive: remove unnecessary notifies from DirChangeNotify

Fabian Möllera3dd2c691e26
diff --git a/backend/amazonclouddrive/amazonclouddrive.go b/backend/amazonclouddrive/amazonclouddrive.go
index 569f97bff..e7d6486dc 100644
--- a/backend/amazonclouddrive/amazonclouddrive.go
+++ b/backend/amazonclouddrive/amazonclouddrive.go
@@ -1264,21 +1264,17 @@ func (f *Fs) dirchangeNotifyRunner(notifyFunc func(string), checkpoint string) s
if path, ok := f.dirCache.GetInv(*node.Id); ok {
pathsToClear = append(pathsToClear, path)
}
-
- for _, parent := range node.Parents {
- if path, ok := f.dirCache.GetInv(parent); ok {
- pathsToClear = append(pathsToClear, path)
- }
- }
}
+ notified := false
lastNotifiedPath := ""
sort.Strings(pathsToClear)
for _, path := range pathsToClear {
- if lastNotifiedPath != "" && (path == lastNotifiedPath || strings.HasPrefix(path+"/", lastNotifiedPath)) {
+ if notified && strings.HasPrefix(path+"/", lastNotifiedPath+"/") {
continue
}
lastNotifiedPath = path
+ notified = true
notifyFunc(path)
}