fix race/panic on modify+delete

This fixes a race condition when a file is modified and unlinked in the OS before the inotify IsModify event has a chance to call os.Stat.
This commit is contained in:
presbrey 2013-09-20 12:47:55 -04:00 committed by joe
parent 45a47abe0e
commit afd80c034c
1 changed files with 4 additions and 0 deletions

View File

@ -97,6 +97,10 @@ func (fw *InotifyFileWatcher) ChangeEvents(t tomb.Tomb, fi os.FileInfo) *FileCha
case evt.IsModify(): case evt.IsModify():
fi, err := os.Stat(fw.Filename) fi, err := os.Stat(fw.Filename)
if err != nil { if err != nil {
if os.IsNotExist(err) {
changes.NotifyDeleted()
return
}
// XXX: no panic here // XXX: no panic here
panic(err) panic(err)
} }