aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-11-05 22:35:41 -0800
committerchrislu <chris.lu@gmail.com>2025-11-05 22:35:41 -0800
commit1cd8a591b9137d0e3ce97bedbd857b4c13fc0d94 (patch)
tree4cedc3802d3ed6d7928e2da2ba6dcf4140e06f62
parent36ddaaaf9120d95b722413b2dba4b986ff110e73 (diff)
downloadseaweedfs-1cd8a591b9137d0e3ce97bedbd857b4c13fc0d94.tar.xz
seaweedfs-1cd8a591b9137d0e3ce97bedbd857b4c13fc0d94.zip
determine stopAtPath
-rw-r--r--weed/filer/filer.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/weed/filer/filer.go b/weed/filer/filer.go
index 36273afff..9fceb879c 100644
--- a/weed/filer/filer.go
+++ b/weed/filer/filer.go
@@ -435,7 +435,23 @@ func (f *Filer) doListDirectoryEntries(ctx context.Context, p util.FullPath, sta
// DeleteEmptyParentDirectories has built-in protection against deleting bucket directories
if deletedCount > 0 && !hasValidEntries && p != "/" && startFileName == "" {
glog.V(2).InfofCtx(ctx, "doListDirectoryEntries: deleted %d expired entries from %s, checking for empty directory cleanup", deletedCount, p)
- stopAtPath := util.FullPath(f.DirBucketsPath)
+
+ // Determine appropriate stop path based on whether this is an S3 path
+ var stopAtPath util.FullPath
+ if strings.HasPrefix(string(p), f.DirBucketsPath+"/") {
+ // S3 path: stop at the bucket root (e.g., /buckets/mybucket)
+ pathAfterBuckets := string(p)[len(f.DirBucketsPath)+1:]
+ parts := strings.SplitN(pathAfterBuckets, "/", 2)
+ if len(parts) > 0 {
+ stopAtPath = util.NewFullPath(f.DirBucketsPath, parts[0])
+ } else {
+ stopAtPath = util.FullPath(f.DirBucketsPath)
+ }
+ } else {
+ // Non-S3 path: allow cleanup up to root
+ stopAtPath = "/"
+ }
+
f.DeleteEmptyParentDirectories(opCtx, p, stopAtPath)
}
}