From 2022c4bce6ad89cbac58854c717bd54014fc4199 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 16 Sep 2013 09:16:22 -0400 Subject: [PATCH] fix wait_index --- file_system/watcher.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/file_system/watcher.go b/file_system/watcher.go index 728d11fd4..20a679a64 100644 --- a/file_system/watcher.go +++ b/file_system/watcher.go @@ -13,8 +13,9 @@ type watcherHub struct { } type watcher struct { - eventChan chan *Event - recursive bool + eventChan chan *Event + recursive bool + sinceIndex uint64 } func newWatchHub(capacity int) *watcherHub { @@ -43,8 +44,9 @@ func (wh *watcherHub) watch(prefix string, recursive bool, index uint64) (<-chan } w := &watcher{ - eventChan: eventChan, - recursive: recursive, + eventChan: eventChan, + recursive: recursive, + sinceIndex: index, } l, ok := wh.watchers[prefix] @@ -85,7 +87,7 @@ func (wh *watcherHub) notifyWithPath(e *Event, path string, force bool) { w, _ := curr.Value.(*watcher) - if w.recursive || force || e.Key == path { + if (w.recursive || force || e.Key == path) && e.Index >= w.sinceIndex { w.eventChan <- e l.Remove(curr) } else {