From bf39eb4f5114c78b6af77220a1fe7197753192cb Mon Sep 17 00:00:00 2001 From: TerraTech Date: Thu, 8 Sep 2016 17:51:15 -0700 Subject: [PATCH] inotify.go: Fix bug where inotify returns IN_ATTRIB against an open fd --- watch/inotify.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/watch/inotify.go b/watch/inotify.go index 4478f1e..948fee1 100644 --- a/watch/inotify.go +++ b/watch/inotify.go @@ -95,6 +95,15 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange } switch { + //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) { + return + } + } + fallthrough + case evt.Op&fsnotify.Remove == fsnotify.Remove: fallthrough