]> go.fuhry.dev Git - fsnotify.git/commitdiff
kqueue: addWatch sometimes just watches deletions
authorNathan Youngman <git@nathany.com>
Sat, 13 Dec 2014 04:47:51 +0000 (21:47 -0700)
committerNathan Youngman <git@nathany.com>
Sat, 13 Dec 2014 06:13:37 +0000 (23:13 -0700)
fix regression #48

When watching a directory with kqueue, fsnotify will watch all the files in it. This includes subdirectories, but it only watches for the subdirectory being deleted. This is to emulate the behavior of inotify on Linux.

A bug in 4a0d1ae9df8c61fb8912829fc714f189358a3dc7 resulted in it watching that subdirectory for all events, so watching a single directory would result in more events than expected.

CHANGELOG.md
kqueue.go

index 2443d4d9b9cbd1298759ed3d8aa8257bde50122a..93c93394dbd60dd2dd214bc8a87aee870b568d29 100644 (file)
@@ -1,6 +1,6 @@
 # Changelog
 
-## dev / 2014-09-24
+## dev / 2014-12-12
 
 * kqueue: rework internals [#43](https://github.com/go-fsnotify/fsnotify/pull/43)
     * add low-level functions
@@ -9,6 +9,7 @@
     * done can be an unbuffered channel
     * remove calls to os.NewSyscallError
 * More efficient string concatenation for Event.String() [#52](https://github.com/go-fsnotify/fsnotify/pull/52) (thanks @mdlayher)
+* kqueue: fix regression in  rework causing subdirectories to be watched [#48](https://github.com/go-fsnotify/fsnotify/issues/48)
 
 ## v1.0.4 / 2014-09-07
 
index 34446521bc881ffb3940a20049867e030890d8ff..545c6c9d298fa5f1c4f3688fb34f1c85f35de9c8 100644 (file)
--- a/kqueue.go
+++ b/kqueue.go
@@ -204,7 +204,7 @@ func (w *Watcher) addWatch(name string, flags uint32) error {
        }
 
        const registerAdd = syscall.EV_ADD | syscall.EV_CLEAR | syscall.EV_ENABLE
-       if err := register(w.kq, []int{watchfd}, registerAdd, noteAllEvents); err != nil {
+       if err := register(w.kq, []int{watchfd}, registerAdd, flags); err != nil {
                syscall.Close(watchfd)
                return err
        }