diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-08-01 01:26:41 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-08-01 01:26:41 -0700 |
| commit | c81f1cda47ffb9e69d6d0ba02358d8a1e7df9afa (patch) | |
| tree | d8df6f40b777e55bc78df597fe483800b4911026 | |
| parent | fa3ded41347602c458931553c3567662d151fd5e (diff) | |
| download | seaweedfs-c81f1cda47ffb9e69d6d0ba02358d8a1e7df9afa.tar.xz seaweedfs-c81f1cda47ffb9e69d6d0ba02358d8a1e7df9afa.zip | |
correctly recursively delete folders
| -rw-r--r-- | weed/filer2/filer.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go index 1f2697cda..823371a6b 100644 --- a/weed/filer2/filer.go +++ b/weed/filer2/filer.go @@ -13,6 +13,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/wdclient" "github.com/karlseguin/ccache" + "math" ) type Filer struct { @@ -141,7 +142,11 @@ func (f *Filer) DeleteEntryMetaAndData(p FullPath, isRecursive bool, shouldDelet } if entry.IsDirectory() { - entries, err := f.ListDirectoryEntries(p, "", false, 1) + limit := int(1) + if isRecursive { + limit = math.MaxInt32 + } + entries, err := f.ListDirectoryEntries(p, "", false, limit) if err != nil { return fmt.Errorf("list folder %s: %v", p, err) } @@ -161,6 +166,10 @@ func (f *Filer) DeleteEntryMetaAndData(p FullPath, isRecursive bool, shouldDelet f.deleteChunks(entry.Chunks) } + if p == "/" { + return nil + } + glog.V(0).Infof("deleting entry %v", p) return f.store.DeleteEntry(p) } |
