Browse Source

fix(store.go) send event to watcher after we finish modifying it

Xiang Li 11 years ago
parent
commit
a9dff278b5
1 changed files with 3 additions and 2 deletions
  1. 3 2
      store/store.go

+ 3 - 2
store/store.go

@@ -135,6 +135,7 @@ func (s *store) Create(nodePath string, dir bool, value string, unique bool, exp
 	e, err := s.internalCreate(nodePath, dir, value, unique, false, expireTime, Create)
 	e, err := s.internalCreate(nodePath, dir, value, unique, false, expireTime, Create)
 
 
 	if err == nil {
 	if err == nil {
+		s.WatcherHub.notify(e)
 		s.Stats.Inc(CreateSuccess)
 		s.Stats.Inc(CreateSuccess)
 	} else {
 	} else {
 		s.Stats.Inc(CreateFail)
 		s.Stats.Inc(CreateFail)
@@ -178,6 +179,8 @@ func (s *store) Set(nodePath string, dir bool, value string, expireTime time.Tim
 		e.PrevNode = prev.Node
 		e.PrevNode = prev.Node
 	}
 	}
 
 
+	s.WatcherHub.notify(e)
+
 	return e, nil
 	return e, nil
 }
 }
 
 
@@ -524,8 +527,6 @@ func (s *store) internalCreate(nodePath string, dir bool, value string, unique,
 
 
 	s.CurrentIndex = nextIndex
 	s.CurrentIndex = nextIndex
 
 
-	s.WatcherHub.notify(e)
-
 	return e, nil
 	return e, nil
 }
 }