aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-05-19 12:07:15 -0700
committerChris Lu <chris.lu@gmail.com>2018-05-19 12:07:15 -0700
commitab4ddb1e0ee425d0d779eb529c42dc5361320822 (patch)
tree9d31d09bd934830e59f7f9518d9c85abff89ef55 /weed/filer2
parente31c514b00b97c2db20232812899d542e37ea931 (diff)
downloadseaweedfs-ab4ddb1e0ee425d0d779eb529c42dc5361320822.tar.xz
seaweedfs-ab4ddb1e0ee425d0d779eb529c42dc5361320822.zip
fix directory creation, directory listing
Diffstat (limited to 'weed/filer2')
-rw-r--r--weed/filer2/filer.go11
-rw-r--r--weed/filer2/memdb/memdb_store.go8
2 files changed, 13 insertions, 6 deletions
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go
index 4ee6f4e50..467f846ed 100644
--- a/weed/filer2/filer.go
+++ b/weed/filer2/filer.go
@@ -9,6 +9,7 @@ import (
"time"
"os"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/chrislusf/seaweedfs/weed/glog"
)
type Filer struct {
@@ -44,22 +45,23 @@ func (f *Filer) CreateEntry(entry *Entry) (error) {
dirPath := "/" + filepath.Join(dirParts[:i]...)
// fmt.Printf("%d directory: %+v\n", i, dirPath)
- dirFound := false
-
// first check local cache
dirEntry := f.cacheGetDirectory(dirPath)
// not found, check the store directly
if dirEntry == nil {
+ glog.V(4).Infof("find uncached directory: %s", dirPath)
var dirFindErr error
- dirFound, dirEntry, dirFindErr = f.FindEntry(FullPath(dirPath))
+ _, dirEntry, dirFindErr = f.FindEntry(FullPath(dirPath))
if dirFindErr != nil {
return fmt.Errorf("findDirectory %s: %v", dirPath, dirFindErr)
}
+ }else{
+ glog.V(4).Infof("found cached directory: %s", dirPath)
}
// no such existing directory
- if !dirFound {
+ if dirEntry == nil {
// create the directory
now := time.Now()
@@ -75,6 +77,7 @@ func (f *Filer) CreateEntry(entry *Entry) (error) {
},
}
+ glog.V(2).Infof("create directory: %s", dirPath)
mkdirErr := f.store.InsertEntry(dirEntry)
if mkdirErr != nil {
return fmt.Errorf("mkdir %s: %v", dirPath, mkdirErr)
diff --git a/weed/filer2/memdb/memdb_store.go b/weed/filer2/memdb/memdb_store.go
index 0276e9a7f..7e886f4ef 100644
--- a/weed/filer2/memdb/memdb_store.go
+++ b/weed/filer2/memdb/memdb_store.go
@@ -77,11 +77,13 @@ func (filer *MemDbStore) ListDirectoryEntries(fullpath filer2.FullPath, startFil
}
entry := item.(Entry).Entry
// println("checking", entry.FullPath)
+
if entry.FullPath == fullpath {
// skipping the current directory
// println("skipping the folder", entry.FullPath)
return true
}
+
dir, name := entry.FullPath.DirAndName()
if name == startFileName {
if inclusive {
@@ -90,11 +92,13 @@ func (filer *MemDbStore) ListDirectoryEntries(fullpath filer2.FullPath, startFil
}
return true
}
- if !strings.HasPrefix(dir, string(fullpath)) {
- // println("directory is:", dir, "fullpath:", fullpath)
+
+ // only iterate the same prefix
+ if !strings.HasPrefix(string(entry.FullPath), string(fullpath)) {
// println("breaking from", entry.FullPath)
return false
}
+
if dir != string(fullpath) {
// this could be items in deeper directories
// println("skipping deeper folder", entry.FullPath)