diff --git a/pkg/watch/notify_test.go b/pkg/watch/notify_test.go index 90d1578d4..43a6f31f9 100644 --- a/pkg/watch/notify_test.go +++ b/pkg/watch/notify_test.go @@ -231,6 +231,7 @@ func TestSingleFile(t *testing.T) { if err != nil { t.Fatal(err) } + f.fsync() d2 := []byte("hello\nworld\n") err = ioutil.WriteFile(path, d2, 0644) diff --git a/pkg/watch/watcher_darwin.go b/pkg/watch/watcher_darwin.go index aa50d78fc..0b7a7fa57 100644 --- a/pkg/watch/watcher_darwin.go +++ b/pkg/watch/watcher_darwin.go @@ -34,7 +34,7 @@ func (d *darwinNotify) isTrackingPath(path string) bool { } func (d *darwinNotify) loop() { - ignoredSpuriousEvent := false + ignoredSpuriousEvents := make(map[string]bool, 0) for { select { case <-d.stop: @@ -50,8 +50,8 @@ func (d *darwinNotify) loop() { // ignore the first event that says the watched directory // has been created. these are fired spuriously on initiation. if e.Flags&fsevents.ItemCreated == fsevents.ItemCreated { - if d.isTrackingPath(e.Path) && !ignoredSpuriousEvent { - ignoredSpuriousEvent = true + if !ignoredSpuriousEvents[e.Path] && d.isTrackingPath(e.Path) { + ignoredSpuriousEvents[e.Path] = true continue } }