Skip to content

Commit

Permalink
Issue 111: TestReSeekInotify failed
Browse files Browse the repository at this point in the history
if "case fsnotify.Chmod" logic before "case fsnotify.Rename"
always `return changes.NotifyDeleted()`

Test case pass:
macOs 10.11.6 + go 1.6.2
Centos 6.4 + go 1.8
  • Loading branch information
xuzixx committed Mar 5, 2017
1 parent faf842b commit 89ee1af
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions watch/inotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,6 @@ 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

Expand All @@ -113,6 +104,10 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange
changes.NotifyDeleted()
return

//With an open fd, unlink(fd) - inotify returns IN_ATTRIB (==fsnotify.Chmod)
case evt.Op&fsnotify.Chmod == fsnotify.Chmod:
fallthrough

case evt.Op&fsnotify.Write == fsnotify.Write:
fi, err := os.Stat(fw.Filename)
if err != nil {
Expand Down

0 comments on commit 89ee1af

Please sign in to comment.