VOL-1387 : Added watch mechanism
- Fixed a few failure cases
- Adjusted a few logs
Change-Id: Ied1ecb3d8996a338eee00e9643685482700e860b
diff --git a/db/model/node.go b/db/model/node.go
index 017f121..b8daadd 100644
--- a/db/model/node.go
+++ b/db/model/node.go
@@ -301,7 +301,7 @@
names := ChildrenFields(n.Type)
field := names[name]
- if field.IsContainer {
+ if field != nil && field.IsContainer {
children := make([]Revision, len(rev.GetChildren()[name]))
copy(children, rev.GetChildren()[name])
@@ -557,6 +557,10 @@
// Prefix the hash with the data type (e.g. devices, logical_devices, adapters)
childRev.SetHash(name + "/" + key.String())
+
+ // Create watch for <component>/<key>
+ childRev.SetupWatch(childRev.GetHash())
+
children = append(children, childRev)
rev = rev.UpdateChildren(name, children, branch)
changes := []ChangeTuple{{POST_ADD, nil, childRev.GetData()}}