Browse Source
Merge pull request #1883 from kmlebedev/passDelNonEmptyFolder
s3 delete-objects pass OK for fail to delete non-empty folder
pull/1892/head
Chris Lu
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
1 deletions
-
weed/filer/filer_delete_entry.go
-
weed/s3api/s3api_object_handlers.go
|
|
@ -11,6 +11,10 @@ import ( |
|
|
|
|
|
|
|
type HardLinkId []byte |
|
|
|
|
|
|
|
const ( |
|
|
|
MsgFailDelNonEmptyFolder = "fail to delete non-empty folder" |
|
|
|
) |
|
|
|
|
|
|
|
func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isFromOtherCluster bool, signatures []int32) (err error) { |
|
|
|
if p == "/" { |
|
|
|
return nil |
|
|
@ -77,7 +81,7 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry |
|
|
|
if lastFileName == "" && !isRecursive && len(entries) > 0 { |
|
|
|
// only for first iteration in the loop
|
|
|
|
glog.Errorf("deleting a folder %s has children: %+v ...", entry.FullPath, entries[0].Name()) |
|
|
|
return nil, nil, fmt.Errorf("fail to delete non-empty folder: %s", entry.FullPath) |
|
|
|
return nil, nil, fmt.Errorf("%s: %s", MsgFailDelNonEmptyFolder, entry.FullPath) |
|
|
|
} |
|
|
|
|
|
|
|
for _, sub := range entries { |
|
|
|
|
|
@ -5,6 +5,7 @@ import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/xml" |
|
|
|
"fmt" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/filer" |
|
|
|
"io" |
|
|
|
"io/ioutil" |
|
|
|
"net/http" |
|
|
@ -205,6 +206,8 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h |
|
|
|
if err == nil { |
|
|
|
directoriesWithDeletion[parentDirectoryPath]++ |
|
|
|
deletedObjects = append(deletedObjects, object) |
|
|
|
} else if strings.Contains(err.Error(), filer.MsgFailDelNonEmptyFolder) { |
|
|
|
deletedObjects = append(deletedObjects, object) |
|
|
|
} else { |
|
|
|
delete(directoriesWithDeletion, parentDirectoryPath) |
|
|
|
deleteErrors = append(deleteErrors, DeleteError{ |
|
|
|