fix(objectnode): S3 Folder not recursively deleted

Signed-off-by: FourSpaces <cheng1483x@gmail.com>
This commit is contained in:
FourSpaces 2025-03-17 16:19:01 +08:00 committed by leonrayang
parent e8adeff5fa
commit 9cc87735fe

View File

@ -24,6 +24,7 @@ import (
"hash"
"io"
"os"
os_path "path"
"reflect"
"sort"
"strconv"
@ -941,6 +942,20 @@ func (v *Volume) DeletePath(path string) (err error) {
if err = v.mw.Evict(ino, path); err != nil {
log.LogWarnf("DeletePath Evict: path(%v) inode(%v)", path, ino)
}
// Recursive deletion of empty directory
if os_path.Dir(path) == "." {
return
} else {
log.LogInfof("os_path.Dir(path): (%v)", os_path.Dir(path))
if err = v.DeletePath(fmt.Sprintf("%s/", os_path.Dir(path))); err != nil {
log.LogErrorf("Recursive DeletePath: delete path fail: path(%v) err(%v)", path, err)
return
}
return
}
err = nil
return
}