mirror of
https://github.com/rclone/rclone
synced 2024-11-26 04:07:22 +01:00
amazonclouddrive: remove unnecessary notifies from DirChangeNotify
It is unnecessary to notify the node.Parents, because a cahnge event is generated for all involved files and folders in a move from d1/f1 to d2/f1. There will be a event for d1, d2 and f1. Additionally a duplicate notification is resolved when them empty string is in pathsToClear. Related to #2006
This commit is contained in:
parent
38f829842a
commit
a3dd2c691e
@ -1264,21 +1264,17 @@ func (f *Fs) dirchangeNotifyRunner(notifyFunc func(string), checkpoint string) s
|
|||||||
if path, ok := f.dirCache.GetInv(*node.Id); ok {
|
if path, ok := f.dirCache.GetInv(*node.Id); ok {
|
||||||
pathsToClear = append(pathsToClear, path)
|
pathsToClear = append(pathsToClear, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, parent := range node.Parents {
|
|
||||||
if path, ok := f.dirCache.GetInv(parent); ok {
|
|
||||||
pathsToClear = append(pathsToClear, path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notified := false
|
||||||
lastNotifiedPath := ""
|
lastNotifiedPath := ""
|
||||||
sort.Strings(pathsToClear)
|
sort.Strings(pathsToClear)
|
||||||
for _, path := range pathsToClear {
|
for _, path := range pathsToClear {
|
||||||
if lastNotifiedPath != "" && (path == lastNotifiedPath || strings.HasPrefix(path+"/", lastNotifiedPath)) {
|
if notified && strings.HasPrefix(path+"/", lastNotifiedPath+"/") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
lastNotifiedPath = path
|
lastNotifiedPath = path
|
||||||
|
notified = true
|
||||||
notifyFunc(path)
|
notifyFunc(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user