From: Rob Figueiredo Date: Tue, 9 Oct 2012 02:36:22 +0000 (-0400) Subject: Watch the directory even if it isn't a new watch. X-Git-Tag: v1.7.2~398^2 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=432c817ae4d60300a5fbafd190ded5b93d992d5a;p=fsnotify.git Watch the directory even if it isn't a new watch. This fixes the issue where you watch directory and then its subdirectory, the subdirectory does not have all its files watched (via watchDirectoryFiles) --- diff --git a/fsnotify_bsd.go b/fsnotify_bsd.go index 602bd4d..edafb99 100644 --- a/fsnotify_bsd.go +++ b/fsnotify_bsd.go @@ -139,10 +139,12 @@ func (w *Watcher) addWatch(path string, flags uint32) error { w.paths[watchfd] = path w.finfo[watchfd] = fi - if fi.IsDir() && (flags&NOTE_WRITE) == NOTE_WRITE { - watchDir = true - } } + + if w.finfo[watchfd].IsDir() && (flags&NOTE_WRITE) == NOTE_WRITE { + watchDir = true + } + syscall.SetKevent(watchEntry, watchfd, syscall.EVFILT_VNODE, syscall.EV_ADD|syscall.EV_CLEAR) wd, errno := syscall.Kevent(w.kq, w.kbuf[:], nil, nil)