watchEntry := &w.kbuf[0]
watchEntry.Fflags = flags
+ watchDir := false
watchfd, found := w.watches[path]
if !found {
w.finfo[watchfd] = fi
if fi.IsDir() && (flags&NOTE_WRITE) == NOTE_WRITE {
- errdir := w.watchDirectoryFiles(path)
- if errdir != nil {
- return errdir
- }
+ watchDir = true
}
}
syscall.SetKevent(watchEntry, watchfd, syscall.EVFILT_VNODE, syscall.EV_ADD|syscall.EV_CLEAR)
return errors.New("kevent add error")
}
+ if watchDir {
+ errdir := w.watchDirectoryFiles(path)
+ if errdir != nil {
+ return errdir
+ }
+ }
return nil
}
if len(events) == 0 {
n, errno = syscall.Kevent(w.kq, nil, eventbuf[:], twait)
- // EINTR is okay, basically the syscall was interrupted before
+ // EINTR is okay, basically the syscall was interrupted before
// timeout expired.
if errno != nil && errno != syscall.EINTR {
w.Error <- os.NewSyscallError("kevent", errno)
} else {
// Linux gives deletes if not explicitly watching
e := w.addWatch(filePath, NOTE_DELETE)
+ w.fsnFlags[filePath] = FSN_ALL
if e != nil {
return e
}
// sendDirectoryEvents searches the directory for newly created files
// and sends them over the event channel. This functionality is to have
-// the BSD version of fsnotify mach linux fsnotify which provides a
+// the BSD version of fsnotify mach linux fsnotify which provides a
// create event for files created in a watched directory.
func (w *Watcher) sendDirectoryChangeEvents(dirPath string) {
// Get all files