Skip to content

Commit c8a358a

Browse files
nicksndeloof
authored andcommitted
watch: try a slightly different ignore strategy (docker#174)
1 parent a670165 commit c8a358a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

pkg/watch/watcher_darwin.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ type darwinNotify struct {
2222
sm *sync.Mutex
2323

2424
// When a watch is created for a directory, we've seen fsevents non-determistically
25-
// fire 0-2 CREATE events for that directory. We want to ignore these.
26-
ignoreCreatedEvents map[string]int
25+
// fire 0-3 CREATE events for that directory. We want to ignore these.
26+
ignoreCreatedEvents map[string]bool
2727
}
2828

2929
func (d *darwinNotify) loop() {
@@ -41,11 +41,8 @@ func (d *darwinNotify) loop() {
4141

4242
if e.Flags&fsevents.ItemCreated == fsevents.ItemCreated {
4343
d.sm.Lock()
44-
ignoreCount := d.ignoreCreatedEvents[e.Path]
45-
shouldIgnore := ignoreCount > 0
46-
if shouldIgnore {
47-
d.ignoreCreatedEvents[e.Path]--
48-
} else {
44+
shouldIgnore := d.ignoreCreatedEvents[e.Path]
45+
if !shouldIgnore {
4946
// If we got a created event for something
5047
// that's not on the ignore list, we assume
5148
// we're done with the spurious events.
@@ -84,9 +81,9 @@ func (d *darwinNotify) Add(name string) error {
8481
es.Paths = append(es.Paths, name)
8582

8683
if d.ignoreCreatedEvents == nil {
87-
d.ignoreCreatedEvents = make(map[string]int, 1)
84+
d.ignoreCreatedEvents = make(map[string]bool, 1)
8885
}
89-
d.ignoreCreatedEvents[name] = 2
86+
d.ignoreCreatedEvents[name] = true
9087

9188
if len(es.Paths) == 1 {
9289
es.Start()

0 commit comments

Comments
 (0)