mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-22 07:39:24 +08:00
Merge pull request #1883 from kmlebedev/passDelNonEmptyFolder
s3 delete-objects pass OK for fail to delete non-empty folder
This commit is contained in:
@@ -11,6 +11,10 @@ import (
|
|||||||
|
|
||||||
type HardLinkId []byte
|
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) {
|
func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isFromOtherCluster bool, signatures []int32) (err error) {
|
||||||
if p == "/" {
|
if p == "/" {
|
||||||
return nil
|
return nil
|
||||||
@@ -77,7 +81,7 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
|
|||||||
if lastFileName == "" && !isRecursive && len(entries) > 0 {
|
if lastFileName == "" && !isRecursive && len(entries) > 0 {
|
||||||
// only for first iteration in the loop
|
// only for first iteration in the loop
|
||||||
glog.Errorf("deleting a folder %s has children: %+v ...", entry.FullPath, entries[0].Name())
|
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 {
|
for _, sub := range entries {
|
||||||
|
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -205,6 +206,8 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
directoriesWithDeletion[parentDirectoryPath]++
|
directoriesWithDeletion[parentDirectoryPath]++
|
||||||
deletedObjects = append(deletedObjects, object)
|
deletedObjects = append(deletedObjects, object)
|
||||||
|
} else if strings.Contains(err.Error(), filer.MsgFailDelNonEmptyFolder) {
|
||||||
|
deletedObjects = append(deletedObjects, object)
|
||||||
} else {
|
} else {
|
||||||
delete(directoriesWithDeletion, parentDirectoryPath)
|
delete(directoriesWithDeletion, parentDirectoryPath)
|
||||||
deleteErrors = append(deleteErrors, DeleteError{
|
deleteErrors = append(deleteErrors, DeleteError{
|
||||||
|
Reference in New Issue
Block a user