Xiang Li 12 years ago
parent
commit
c56312f09f
2 changed files with 18 additions and 15 deletions
  1. 3 15
      file_system/file_system.go
  2. 15 0
      file_system/node.go

+ 3 - 15
file_system/file_system.go

@@ -1,7 +1,6 @@
 package fileSystem
 
 import (
-	"fmt"
 	"path/filepath"
 	"strings"
 	"time"
@@ -40,23 +39,13 @@ func (fs *FileSystem) Get(path string, recusive bool, index uint64, term uint64)
 
 		i := 0
 
-		for _, subN := range n.Children {
+		for _, child := range n.Children {
 
-			if subN.IsHidden() { // get will not list hidden node
+			if child.IsHidden() { // get will not list hidden node
 				continue
 			}
 
-			if subN.IsDir() {
-				e.KVPairs[i] = KeyValuePair{
-					Key: subN.Path,
-					Dir: true,
-				}
-			} else {
-				e.KVPairs[i] = KeyValuePair{
-					Key:   subN.Path,
-					Value: subN.Value,
-				}
-			}
+			e.KVPairs[i] = child.Pair()
 
 			i++
 		}
@@ -174,7 +163,6 @@ func (fs *FileSystem) walk(path string, walkFunc func(prev *Node, component stri
 
 // InternalGet function get the node of the given path.
 func (fs *FileSystem) InternalGet(path string, index uint64, term uint64) (*Node, error) {
-	fmt.Println("GET: ", path)
 	path = filepath.Clean("/" + path)
 
 	// update file system known index and term

+ 15 - 0
file_system/node.go

@@ -261,3 +261,18 @@ func (n *Node) IsHidden() bool {
 
 	return false
 }
+
+func (n *Node) Pair() KeyValuePair {
+
+	if n.IsDir() {
+		return KeyValuePair{
+			Key: n.Path,
+			Dir: true,
+		}
+	}
+
+	return KeyValuePair{
+		Key:   n.Path,
+		Value: n.Value,
+	}
+}