From 21590655cbc4e5246c480857d1463f270f5d9183 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Wed, 22 Nov 2017 02:57:24 +0100 Subject: [PATCH] backend: detect non-atomic file operation to look at another event --- backend/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/main.go b/backend/main.go index db1f6b18..10e97e0f 100644 --- a/backend/main.go +++ b/backend/main.go @@ -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) }