From 3ddc2282d2b20a50950957b7f1ecb194d67c913f Mon Sep 17 00:00:00 2001 From: Chris Howey Date: Mon, 11 Mar 2013 16:29:55 -0500 Subject: [PATCH] When adding files of directory, use fsnFlags from directory. Fixes issue #33 --- fsnotify_bsd.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fsnotify_bsd.go b/fsnotify_bsd.go index 1c344f0..70f5f27 100644 --- a/fsnotify_bsd.go +++ b/fsnotify_bsd.go @@ -360,11 +360,18 @@ func (w *Watcher) watchDirectoryFiles(dirPath string) error { for _, fileInfo := range files { filePath := filepath.Join(dirPath, fileInfo.Name()) if fileInfo.IsDir() == false { - // Watch file to mimic linux fsnotify - e := w.addWatch(filePath, NOTE_DELETE|NOTE_WRITE|NOTE_RENAME) + // Inherit fsnFlags from parent directory w.fsnmut.Lock() - w.fsnFlags[filePath] = FSN_ALL + dirFsnFlags, dirFsnFound := w.fsnFlags[dirPath] + if dirFsnFound { + w.fsnFlags[filePath] = dirFsnFlags + } else { + w.fsnFlags[filePath] = FSN_ALL + } w.fsnmut.Unlock() + + // Watch file to mimic linux fsnotify + e := w.addWatch(filePath, NOTE_DELETE|NOTE_WRITE|NOTE_RENAME) if e != nil { return e } -- 2.50.1