VOL-1459 : Fix failure to load device from persistence

- fixed watch logic which was not really updating memory
- force get depth to 0 to work around corrupted data structures

Change-Id: I595981e2ee3d816d17702e7f39c099193590fa6f
diff --git a/db/model/node.go b/db/model/node.go
index 7ea4417..7b05f8e 100644
--- a/db/model/node.go
+++ b/db/model/node.go
@@ -249,7 +249,7 @@
 
 // Get retrieves the data from a node tree that resides at the specified path
 func (n *node) List(path string, hash string, depth int, deep bool, txid string) interface{} {
-	log.Debugw("node-list-request", log.Fields{"path": path, "hash": hash, "depth":depth, "deep":deep, "txid":txid})
+	log.Debugw("node-list-request", log.Fields{"path": path, "hash": hash, "depth": depth, "deep": deep, "txid": txid})
 	if deep {
 		depth = -1
 	}
@@ -285,7 +285,7 @@
 
 // Get retrieves the data from a node tree that resides at the specified path
 func (n *node) Get(path string, hash string, depth int, deep bool, txid string) interface{} {
-	log.Debugw("node-get-request", log.Fields{"path": path, "hash": hash, "depth":depth, "deep":deep, "txid":txid})
+	log.Debugw("node-get-request", log.Fields{"path": path, "hash": hash, "depth": depth, "deep": deep, "txid": txid})
 	if deep {
 		depth = -1
 	}
@@ -309,14 +309,19 @@
 
 	var result interface{}
 	if result = n.getPath(rev.GetBranch().GetLatest(), path, depth);
-		reflect.ValueOf(result).IsValid() && reflect.ValueOf(result).IsNil() && n.Root.KvStore != nil {
+		(result == nil || reflect.ValueOf(result).IsValid() && reflect.ValueOf(result).IsNil()) && n.Root.KvStore != nil {
 		// We got nothing from memory, try to pull it from persistence
 		var prList []interface{}
 		if pr := rev.LoadFromPersistence(path, txid); pr != nil {
-			for _, revEntry := range pr {
-				prList = append(prList, revEntry.GetData())
+			// Did we receive a single or multiple revisions?
+			if len(pr) > 1 {
+				for _, revEntry := range pr {
+					prList = append(prList, revEntry.GetData())
+				}
+				result = prList
+			} else {
+				result = pr[0].GetData()
 			}
-			result = prList
 		}
 	}
 
@@ -404,7 +409,7 @@
 
 // Update changes the content of a node at the specified path with the provided data
 func (n *node) Update(path string, data interface{}, strict bool, txid string, makeBranch MakeBranchFunction) Revision {
-	log.Debugw("node-update-request", log.Fields{"path": path, "strict": strict, "txid":txid, "makeBranch": makeBranch})
+	log.Debugw("node-update-request", log.Fields{"path": path, "strict": strict, "txid": txid, "makeBranch": makeBranch})
 
 	for strings.HasPrefix(path, "/") {
 		path = path[1:]
@@ -435,7 +440,6 @@
 		path = partition[1]
 	}
 
-
 	field := ChildrenFields(n.Type)[name]
 	var children []Revision
 
@@ -559,7 +563,7 @@
 
 // Add inserts a new node at the specified path with the provided data
 func (n *node) Add(path string, data interface{}, txid string, makeBranch MakeBranchFunction) Revision {
-	log.Debugw("node-add-request", log.Fields{"path": path, "txid":txid, "makeBranch": makeBranch})
+	log.Debugw("node-add-request", log.Fields{"path": path, "txid": txid, "makeBranch": makeBranch})
 
 	for strings.HasPrefix(path, "/") {
 		path = path[1:]
@@ -669,7 +673,7 @@
 
 // Remove eliminates a node at the specified path
 func (n *node) Remove(path string, txid string, makeBranch MakeBranchFunction) Revision {
-	log.Debugw("node-remove-request", log.Fields{"path": path, "txid":txid, "makeBranch": makeBranch})
+	log.Debugw("node-remove-request", log.Fields{"path": path, "txid": txid, "makeBranch": makeBranch})
 
 	for strings.HasPrefix(path, "/") {
 		path = path[1:]