backend: detect non-atomic file operation to look at another event
This commit is contained in:
parent
4bd8d5f93e
commit
21590655cb
1 changed files with 6 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue