SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
visit parent folder first
Chris Lua808df501932
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.goindex 0851b4142b..0592c78488 100644--- a/weed/filer2/filer.go+++ b/weed/filer2/filer.go@@ -39,7 +39,7 @@ func (f *Filer) CreateEntry(entry Entry) (error) {3. add the file entry*/- f.recursivelyEnsureDirectory(entry.Dir, func(parent, name string) error {+ recursivelyEnsureDirectory(entry.Dir, func(parent, name string) error {return nil})@@ -66,7 +66,7 @@ func (f *Filer) UpdateEntry(entry Entry) (error) {return f.store.UpdateEntry(entry)}-func (f *Filer) recursivelyEnsureDirectory(fullPath string, fn func(parent, name string) error) (error) {+func recursivelyEnsureDirectory(fullPath string, fn func(parent, name string) error) (error) {if strings.HasSuffix(fullPath, "/") {fullPath = fullPath[0:len(fullPath)-1]}@@ -82,11 +82,15 @@ func (f *Filer) recursivelyEnsureDirectory(fullPath string, fn func(parent, nameparentDirPath = "/"}+ if err := recursivelyEnsureDirectory(parentDirPath, fn); err != nil {+ return err+ }+if err := fn(parentDirPath, dirName); err != nil {return err}- return f.recursivelyEnsureDirectory(parentDirPath, fn)+ return nil}func (f *Filer) cacheGetDirectory(dirpath string) (error) {diff --git a/weed/filer2/filer_test.go b/weed/filer2/filer_test.goindex 0cefb679a1..bafc25cf0d 100644--- a/weed/filer2/filer_test.go+++ b/weed/filer2/filer_test.go@@ -7,21 +7,19 @@ import ()func TestRecursion(t *testing.T) {- filer := NewFiler("")-fullPath := "/home/chris/some/file/abc.jpg"expected := []string{- "/home/chris/some", "file",- "/home/chris", "some",- "/home", "chris","/", "home",+ "/home", "chris",+ "/home/chris", "some",+ "/home/chris/some", "file",}dir, _ := filepath.Split(fullPath)i := 0- filer.recursivelyEnsureDirectory(dir, func(parent, name string) error {+ recursivelyEnsureDirectory(dir, func(parent, name string) error {if parent != expected[i] || name != expected[i+1] {t.Errorf("recursive directory is wrong! parent=%s dirName=%s", parent, name)}