diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-05-11 02:27:57 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-05-11 02:27:57 -0700 |
| commit | a808df501932f4691e8cb5b20ee438b3f604bc38 (patch) | |
| tree | a406e4245042bd1b8cc070369a5be8a84619e497 /weed/filer2/filer.go | |
| parent | 8a1d640dc4fd451e34f8e21a66d1ca1231c03585 (diff) | |
| download | seaweedfs-a808df501932f4691e8cb5b20ee438b3f604bc38.tar.xz seaweedfs-a808df501932f4691e8cb5b20ee438b3f604bc38.zip | |
visit parent folder first
Diffstat (limited to 'weed/filer2/filer.go')
| -rw-r--r-- | weed/filer2/filer.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go index 0851b4142..0592c7848 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, name parentDirPath = "/" } + 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) { |
