mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(s3): refuse DeleteBucket while versions or delete markers remain (#5548)
* fix(s3): keep versioned buckets until history is purged Reject DeleteBucket while any account-scoped object metadata remains under the bucket prefix. Cover hidden versions and markers through service, HTTP, and persistent storage tests, and purge them in CLI and Java compatibility cleanup. * test(s3): purge versioned enforcement fixtures Delete every listed object version and marker before removing fixture buckets, repeating the first page so deletions do not invalidate continuation markers. Cover null versions, mixed history, and a page boundary inside one key with a direct bucket absence assertion; register the formerly exempt versioned fixture for cleanup. * test(s3): assert fixture purge removes a null version Seed an untouched object before enabling versioning and assert that ListObjectVersions reports its literal null version ID. This makes the direct purge guardrail exercise the null-version branch as intended. * test(s3): encode versioned fixture keys during purge * test(s3): share SDK bucket cleanup helper
This commit is contained in:
11 files changed
+301
-78
No files matched your search
@@ -498,9 +498,7 @@ public class S3Service implements Resettable, ResourceProvider {
|
||||
}
|
||||
|
||||
private void deleteBucketLocked(String bucketName) {
|
||||
// Check if bucket is empty
|
||||
List<S3Object> objects = listObjects(bucketName, null, null, 1);
|
||||
if (!objects.isEmpty()) {
|
||||
if (!objectStore.scan(key -> key.startsWith(bucketPrefix(bucketName))).isEmpty()) {
|
||||
throw new AwsException("BucketNotEmpty",
|
||||
"The bucket you tried to delete is not empty.", 409);
|
||||
}
|
||||
@@ -6033,6 +6031,10 @@ public class S3Service implements Resettable, ResourceProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private String bucketPrefix(String bucketName) {
|
||||
return bucketName + "/";
|
||||
}
|
||||
|
||||
private String objectKey(String bucketName, String key) {
|
||||
return bucketName + "/" + key;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user