From: Chris Howey Date: Mon, 11 Mar 2013 21:29:55 +0000 (-0500) Subject: When adding files of directory, use fsnFlags from directory. X-Git-Tag: v1.7.2~374^2 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=3ddc2282d2b20a50950957b7f1ecb194d67c913f;p=fsnotify.git When adding files of directory, use fsnFlags from directory. Fixes issue #33 --- 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 }