Skip to content

Commit 74e8fde

Browse files
committed
Fix file existance check
1 parent 79fc686 commit 74e8fde

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

resource_catalogue_fastapi/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ def upload_file_s3(body: str, bucket: str, key: str, error_on_exist: bool = Fals
117117
if e.response["Error"]["Code"] != "404":
118118
logging.error(f"Error checking if file exists: {e}")
119119
raise
120-
if error_on_exist:
121-
logging.error(f"File already exists: {key}")
122-
raise
120+
if error_on_exist and file_existed:
121+
logging.error(f"File already exists: {key}")
122+
raise FileExistsError(f"File already exists: {key}")
123123
try:
124124
s3_client.put_object(Body=body, Bucket=bucket, Key=key)
125125
except ClientError as e:

0 commit comments

Comments
 (0)