aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-11-05 14:42:27 -0800
committerchrislu <chris.lu@gmail.com>2025-11-05 14:42:27 -0800
commitdc69c875a1dc1b1b94371ba7cad1af2cb1a880a5 (patch)
tree78f95d80cf102bbe07dfd1f8085c1930403664c2
parent3cff8846c2460370062387dcc472b28cfc180c97 (diff)
downloadseaweedfs-dc69c875a1dc1b1b94371ba7cad1af2cb1a880a5.tar.xz
seaweedfs-dc69c875a1dc1b1b94371ba7cad1af2cb1a880a5.zip
prevent deleting bucket
-rw-r--r--weed/filer/filer.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/weed/filer/filer.go b/weed/filer/filer.go
index 69b57d749..85600e505 100644
--- a/weed/filer/filer.go
+++ b/weed/filer/filer.go
@@ -486,6 +486,15 @@ func (f *Filer) DeleteEmptyParentDirectories(ctx context.Context, dirPath util.F
return
}
+ // Additional safety: prevent deletion of bucket-level directories
+ // This protects /buckets/mybucket from being deleted even if empty
+ baseDepth := strings.Count(f.DirBucketsPath, "/")
+ dirDepth := strings.Count(string(dirPath), "/")
+ if dirDepth <= baseDepth+1 {
+ glog.V(2).InfofCtx(ctx, "DeleteEmptyParentDirectories: skipping deletion of bucket-level directory %s", dirPath)
+ return
+ }
+
// Check if directory is empty
isEmpty, err := f.IsDirectoryEmpty(ctx, dirPath)
if err != nil {