Skip to content

Commit

Permalink
FIXME: something doesn't seem quite right
Browse files Browse the repository at this point in the history
  • Loading branch information
nathany committed Sep 24, 2014
1 parent 85562dc commit 9e50462
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,20 +327,21 @@ func (w *Watcher) readEvents() {
delete(w.fileExists, event.Name)
w.femut.Unlock()

// Look for a file that may have overwritten this
// (ie mv f1 f2 will delete f2 then create f2)
// Look for a file that may have overwritten this.
// For example, mv f1 f2 will delete f2, then create f2.
fileDir, _ := filepath.Split(event.Name)
fileDir = filepath.Clean(fileDir)
w.wmut.Lock()
_, found := w.watches[fileDir]
w.wmut.Unlock()
if found {
// make sure the directory exist before we watch for changes. When we
// make sure the directory exists before we watch for changes. When we
// do a recursive watch and perform rm -fr, the parent directory might
// have gone missing, ignore the missing directory and let the
// upcoming delete event remove the watch from the parent directory.
if _, err := os.Lstat(fileDir); !os.IsNotExist(err) {
if _, err := os.Lstat(fileDir); os.IsExist(err) {
w.sendDirectoryChangeEvents(fileDir)
// FIXME: should this be for events on files or just isDir?
}
}
}
Expand Down

0 comments on commit 9e50462

Please sign in to comment.