From: Nathan Youngman Date: Sat, 13 Dec 2014 04:47:51 +0000 (-0700) Subject: kqueue: addWatch sometimes just watches deletions X-Git-Tag: v1.7.2~250 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=c5335bbee2c0449af1f30cea3caa6a7be9e42efd;p=fsnotify.git kqueue: addWatch sometimes just watches deletions 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. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 2443d4d..93c9339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/kqueue.go b/kqueue.go index 3444652..545c6c9 100644 --- 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 }