Switch empty-folder cleanup to bucket policy (#8292)

* Fix Spark _temporary cleanup and add issue #8285 regression test

* Generalize empty folder cleanup for Spark temp artifacts

* Revert synchronous folder pruning and add cleanup diagnostics

* Add actionable empty-folder cleanup diagnostics

* Fix Spark temp marker cleanup in async folder cleaner

* Fix Spark temp cleanup with implicit directory markers

* Keep explicit directory markers non-implicit

* logging

* more logs

* Switch empty-folder cleanup to bucket policy

* Seaweed-X-Amz-Allow-Empty-Folders

* less logs

* go vet

* less logs

* refactoring
This commit is contained in:
Chris Lu
2026-02-10 18:38:38 -08:00
committed by GitHub
parent 5c365e7090
commit b57429ef2e
16 changed files with 798 additions and 157 deletions

33
weed/util/buckets.go Normal file
View File

@@ -0,0 +1,33 @@
package util
import "strings"
// ExtractBucketPath returns the bucket path under basePath that contains target.
// If requireChild is true, the target must include additional segments beyond the bucket itself.
func ExtractBucketPath(basePath, target string, requireChild bool) (string, bool) {
cleanBase := strings.TrimSuffix(basePath, "/")
if cleanBase == "" {
return "", false
}
prefix := cleanBase + "/"
if !strings.HasPrefix(target, prefix) {
return "", false
}
rest := strings.TrimPrefix(target, prefix)
if rest == "" {
return "", false
}
bucketName, _, found := strings.Cut(rest, "/")
if bucketName == "" {
return "", false
}
if requireChild && !found {
return "", false
}
return prefix + bucketName, true
}