aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-11-05 20:44:22 -0800
committerchrislu <chris.lu@gmail.com>2025-11-05 20:44:22 -0800
commit9612457a32534e230ef75c9a2254bf90d12ad83d (patch)
tree6c7fed59d4a631d8c1f10cb2c81ad11014d902ea
parent9866287d8d3f50f6ad5fefc003e7651f67737607 (diff)
downloadseaweedfs-9612457a32534e230ef75c9a2254bf90d12ad83d.tar.xz
seaweedfs-9612457a32534e230ef75c9a2254bf90d12ad83d.zip
Safety check
-rw-r--r--weed/filer/filer.go5
-rw-r--r--weed/pb/filer_pb/filer_client.go5
2 files changed, 6 insertions, 4 deletions
diff --git a/weed/filer/filer.go b/weed/filer/filer.go
index 7189b9064..d3d2de948 100644
--- a/weed/filer/filer.go
+++ b/weed/filer/filer.go
@@ -454,8 +454,9 @@ func (f *Filer) DeleteEmptyParentDirectories(ctx context.Context, dirPath util.F
return
}
- // Safety check: if stopAtPath is provided, dirPath must be under it
- if stopAtPath != "" && !strings.HasPrefix(string(dirPath)+"/", string(stopAtPath)+"/") {
+ // Safety check: if stopAtPath is provided, dirPath must be under it (root "/" allows everything)
+ stopStr := string(stopAtPath)
+ if stopAtPath != "" && stopStr != "/" && !strings.HasPrefix(string(dirPath)+"/", stopStr+"/") {
glog.V(1).InfofCtx(ctx, "DeleteEmptyParentDirectories: %s is not under %s, skipping", dirPath, stopAtPath)
return
}
diff --git a/weed/pb/filer_pb/filer_client.go b/weed/pb/filer_pb/filer_client.go
index a4e875033..17953c67d 100644
--- a/weed/pb/filer_pb/filer_client.go
+++ b/weed/pb/filer_pb/filer_client.go
@@ -327,8 +327,9 @@ func DoDeleteEmptyParentDirectories(ctx context.Context, client SeaweedFilerClie
checked[dirPathStr] = true
}
- // Safety check: if stopAtPath is provided, dirPath must be under it
- if stopAtPath != "" && !strings.HasPrefix(dirPathStr+"/", string(stopAtPath)+"/") {
+ // Safety check: if stopAtPath is provided, dirPath must be under it (root "/" allows everything)
+ stopStr := string(stopAtPath)
+ if stopAtPath != "" && stopStr != "/" && !strings.HasPrefix(dirPathStr+"/", stopStr+"/") {
glog.V(1).InfofCtx(ctx, "DoDeleteEmptyParentDirectories: %s is not under %s, skipping", dirPath, stopAtPath)
return
}