From 2e79377851962f5983a4cd8ccda689920fb6ef9f Mon Sep 17 00:00:00 2001 From: Vlad Losev Date: Mon, 20 Mar 2017 18:08:26 -0700 Subject: [PATCH] Restores error propagation from fsnotify.Watcher.Add. --- watch/inotify.go | 2 +- watch/inotify_tracker.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/watch/inotify.go b/watch/inotify.go index 4f6c031..f94ebdb 100644 --- a/watch/inotify.go +++ b/watch/inotify.go @@ -99,7 +99,7 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange //With an open fd, unlink(fd) - inotify returns IN_ATTRIB (==fsnotify.Chmod) case evt.Op&fsnotify.Chmod == fsnotify.Chmod: if _, err := os.Stat(fw.Filename); err != nil { - if ! os.IsNotExist(err) { + if !os.IsNotExist(err) { return } } diff --git a/watch/inotify_tracker.go b/watch/inotify_tracker.go index 707e0fa..d68ab61 100644 --- a/watch/inotify_tracker.go +++ b/watch/inotify_tracker.go @@ -153,7 +153,9 @@ func (shared *InotifyTracker) addWatch(winfo *watchInfo) error { if shared.watchNums[fname] == 0 { err = shared.watcher.Add(fname) } - shared.watchNums[fname]++ + if err == nil { + shared.watchNums[fname]++ + } return err }