mirror of
https://github.com/docker/compose.git
synced 2025-07-25 22:54:54 +02:00
watch: try a slightly different ignore strategy (#174)
This commit is contained in:
parent
a6701652d2
commit
c8a358a455
@ -22,8 +22,8 @@ type darwinNotify struct {
|
|||||||
sm *sync.Mutex
|
sm *sync.Mutex
|
||||||
|
|
||||||
// When a watch is created for a directory, we've seen fsevents non-determistically
|
// When a watch is created for a directory, we've seen fsevents non-determistically
|
||||||
// fire 0-2 CREATE events for that directory. We want to ignore these.
|
// fire 0-3 CREATE events for that directory. We want to ignore these.
|
||||||
ignoreCreatedEvents map[string]int
|
ignoreCreatedEvents map[string]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *darwinNotify) loop() {
|
func (d *darwinNotify) loop() {
|
||||||
@ -41,11 +41,8 @@ func (d *darwinNotify) loop() {
|
|||||||
|
|
||||||
if e.Flags&fsevents.ItemCreated == fsevents.ItemCreated {
|
if e.Flags&fsevents.ItemCreated == fsevents.ItemCreated {
|
||||||
d.sm.Lock()
|
d.sm.Lock()
|
||||||
ignoreCount := d.ignoreCreatedEvents[e.Path]
|
shouldIgnore := d.ignoreCreatedEvents[e.Path]
|
||||||
shouldIgnore := ignoreCount > 0
|
if !shouldIgnore {
|
||||||
if shouldIgnore {
|
|
||||||
d.ignoreCreatedEvents[e.Path]--
|
|
||||||
} else {
|
|
||||||
// If we got a created event for something
|
// If we got a created event for something
|
||||||
// that's not on the ignore list, we assume
|
// that's not on the ignore list, we assume
|
||||||
// we're done with the spurious events.
|
// we're done with the spurious events.
|
||||||
@ -84,9 +81,9 @@ func (d *darwinNotify) Add(name string) error {
|
|||||||
es.Paths = append(es.Paths, name)
|
es.Paths = append(es.Paths, name)
|
||||||
|
|
||||||
if d.ignoreCreatedEvents == nil {
|
if d.ignoreCreatedEvents == nil {
|
||||||
d.ignoreCreatedEvents = make(map[string]int, 1)
|
d.ignoreCreatedEvents = make(map[string]bool, 1)
|
||||||
}
|
}
|
||||||
d.ignoreCreatedEvents[name] = 2
|
d.ignoreCreatedEvents[name] = true
|
||||||
|
|
||||||
if len(es.Paths) == 1 {
|
if len(es.Paths) == 1 {
|
||||||
es.Start()
|
es.Start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user