aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-09-11 20:26:20 -0700
committerChris Lu <chris.lu@gmail.com>2019-09-11 20:26:20 -0700
commitae53f636804e41c2c7a0817e8f35434a00b6eacb (patch)
tree82bbdbcf4b454cb506934847e26076cfdd79e4b7 /weed/filer2
parent5e9c65469ecf3356fa02b1cef246d83abdb02d14 (diff)
downloadseaweedfs-ae53f636804e41c2c7a0817e8f35434a00b6eacb.tar.xz
seaweedfs-ae53f636804e41c2c7a0817e8f35434a00b6eacb.zip
filer: recursive deletion optionally ignoring any errors
fix https://github.com/chrislusf/seaweedfs/issues/1062
Diffstat (limited to 'weed/filer2')
-rw-r--r--weed/filer2/filer.go6
-rw-r--r--weed/filer2/memdb/memdb_store_test.go2
2 files changed, 4 insertions, 4 deletions
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go
index cf236b74d..672295dea 100644
--- a/weed/filer2/filer.go
+++ b/weed/filer2/filer.go
@@ -203,7 +203,7 @@ func (f *Filer) FindEntry(ctx context.Context, p FullPath) (entry *Entry, err er
return f.store.FindEntry(ctx, p)
}
-func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p FullPath, isRecursive bool, shouldDeleteChunks bool) (err error) {
+func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p FullPath, isRecursive bool, ignoreRecursiveError, shouldDeleteChunks bool) (err error) {
entry, err := f.FindEntry(ctx, p)
if err != nil {
return err
@@ -230,8 +230,8 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p FullPath, isRecurs
if isRecursive {
for _, sub := range entries {
lastFileName = sub.Name()
- err = f.DeleteEntryMetaAndData(ctx, sub.FullPath, isRecursive, shouldDeleteChunks)
- if err != nil {
+ err = f.DeleteEntryMetaAndData(ctx, sub.FullPath, isRecursive, ignoreRecursiveError, shouldDeleteChunks)
+ if err != nil && !ignoreRecursiveError {
return err
}
limit--
diff --git a/weed/filer2/memdb/memdb_store_test.go b/weed/filer2/memdb/memdb_store_test.go
index d823c5177..3fd806aeb 100644
--- a/weed/filer2/memdb/memdb_store_test.go
+++ b/weed/filer2/memdb/memdb_store_test.go
@@ -139,7 +139,7 @@ func TestCreateFileAndList(t *testing.T) {
}
// delete file and count
- filer.DeleteEntryMetaAndData(ctx, file3Path, false, false)
+ filer.DeleteEntryMetaAndData(ctx, file3Path, false, false, false)
entries, _ = filer.ListDirectoryEntries(ctx, filer2.FullPath("/home/chris/this/is"), "", false, 100)
if len(entries) != 1 {
t.Errorf("list entries count: %v", len(entries))