Skip to content

Commit 49d2735

Browse files
fix:s3: create s3 bucket only if it don't already exists
1 parent a8ff546 commit 49d2735

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

exodus/exodus/core/storage.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ def __init__(self, prefix=''):
1313
secret_key=settings.MINIO_STORAGE_SECRET_KEY,
1414
secure=settings.MINIO_STORAGE_USE_HTTPS)
1515
# Create Minio storage if needed
16-
try:
17-
self.minio_client.make_bucket(settings.MINIO_STORAGE_MEDIA_BUCKET_NAME, location="")
18-
except MinioException:
19-
logging.error(f"An error occured while creating new bucket '{settings.MINIO_STORAGE_MEDIA_BUCKET_NAME}'")
20-
pass
16+
if not self.minio_client.bucket_exists(settings.MINIO_STORAGE_MEDIA_BUCKET_NAME):
17+
try:
18+
self.minio_client.make_bucket(settings.MINIO_STORAGE_MEDIA_BUCKET_NAME, location="")
19+
except MinioException:
20+
logging.error(f"An error occured while creating new bucket '{settings.MINIO_STORAGE_MEDIA_BUCKET_NAME}'")
21+
pass
2122

2223
def get_prefix(self):
2324
return self.prefix

0 commit comments

Comments
 (0)