]> go.fuhry.dev Git - fsnotify.git/commitdiff
When adding files of directory, use fsnFlags from directory.
authorChris Howey <chris@howey.me>
Mon, 11 Mar 2013 21:29:55 +0000 (16:29 -0500)
committerChris Howey <chris@howey.me>
Mon, 11 Mar 2013 21:29:55 +0000 (16:29 -0500)
Fixes issue #33

fsnotify_bsd.go

index 1c344f016071305049ed148703d9efc425d4b6a0..70f5f27aadaa884045502af358f2a07eeb0be3dd 100644 (file)
@@ -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
                        }