delete from the deepest directory first when checking empty folders
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
||||||
@@ -204,11 +205,20 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// purge empty folders, only checking folders with deletions
|
// purge empty folders, only checking folders with deletions
|
||||||
for dir, deletionCount := range directoriesWithDeletion {
|
var allDirs []string
|
||||||
|
for dir, _ := range directoriesWithDeletion {
|
||||||
|
allDirs = append(allDirs, dir)
|
||||||
|
}
|
||||||
|
sort.Slice(allDirs, func(i, j int) bool {
|
||||||
|
return len(allDirs[i]) > len(allDirs[j])
|
||||||
|
})
|
||||||
|
for _, dir := range allDirs {
|
||||||
parentDir, dirName := util.FullPath(dir).DirAndName()
|
parentDir, dirName := util.FullPath(dir).DirAndName()
|
||||||
if err := doDeleteEntry(client, parentDir, dirName, false, false); err != nil {
|
if err := doDeleteEntry(client, parentDir, dirName, false, false); err != nil {
|
||||||
glog.V(4).Infof("directory %s has %d deletion but still not empty: %v", dir, deletionCount, err)
|
glog.V(4).Infof("directory %s has %d deletion but still not empty: %v", dir, directoriesWithDeletion[dir], err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user