backend: detect non-atomic file operation to look at another event

This commit is contained in:
nemunaire 2017-11-22 02:57:24 +01:00 committed by Pierre-Olivier Mercier
commit 21590655cb

View file

@ -109,6 +109,8 @@ func main() {
log.Fatal(err)
}
watchedNotify := fsnotify.Create
for {
select {
case ev := <-watcher.Events:
@ -117,8 +119,11 @@ func main() {
if err := watchsubdir(watcher, ev.Name); err != nil {
log.Println(err)
}
} else if ev.Op & fsnotify.Create == fsnotify.Create {
} else if ev.Op & watchedNotify == watchedNotify {
go treat(ev.Name)
} else if ev.Op & fsnotify.Write == fsnotify.Write {
log.Println("FSNOTIFY WRITE SEEN. Prefer looking at them, as it appears files are not atomically moved.")
watchedNotify = fsnotify.Write
} else if *debugINotify {
log.Println("Skipped event:", ev, "for", ev.Name)
}