attempt to harden ensure_bucket reliability
Docker server image / build-and-push (push) Successful in 3m20s
Docker server image / build-and-push (push) Successful in 3m20s
This commit is contained in:
@@ -39,9 +39,19 @@ class S3Store:
|
||||
)
|
||||
|
||||
def ensure_bucket(self, bucket_name: str) -> None:
|
||||
"""Create a bucket if it does not already exist."""
|
||||
if not self._client.bucket_exists(bucket_name):
|
||||
"""Create a bucket if it does not already exist.
|
||||
|
||||
Uses CreateBucket only, not HeadBucket. Some S3-compatible stores
|
||||
(including SeaweedFS) mishandle or over-restrict HeadBucket; the MinIO
|
||||
client's bucket_exists() maps non-NoSuchBucket errors to failures.
|
||||
Idempotent create covers the same contract with fewer round trips.
|
||||
"""
|
||||
try:
|
||||
self._client.make_bucket(bucket_name)
|
||||
except S3Error as exc:
|
||||
if exc.code in ("BucketAlreadyOwnedByYou", "BucketAlreadyExists"):
|
||||
return
|
||||
raise
|
||||
|
||||
def presigned_put_url(self, bucket_name: str, object_key: str, *, ttl_seconds: int) -> str:
|
||||
"""Generate a presigned PUT URL for a single object upload."""
|
||||
|
||||
Reference in New Issue
Block a user