Skip to content

Commit

Permalink
fix(s3): Use correct credentials to delete files
Browse files Browse the repository at this point in the history
  • Loading branch information
cogk committed Nov 14, 2024
1 parent 682f648 commit 72b56a8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions press/press/doctype/remote_file/remote_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def poll_file_statuses():
"region": default_region,
"access_key_id": aws_access_key,
"secret_access_key": aws_secret_key,
"endpoint_url": press_settings.offsite_backups_endpoint,
},
{
"name": press_settings.remote_uploads_bucket,
Expand Down Expand Up @@ -276,19 +277,27 @@ def delete_s3_files(buckets):
if bucket_name == press_settings.aws_s3_bucket:
endpoint_url = press_settings.offsite_backups_endpoint
region_name = press_settings.backup_region
aws_access_key_id = press_settings.aws_access_key_id
aws_secret_access_key = press_settings.aws_secret_access_key
elif bucket_name == press_settings.remote_uploads_bucket:
endpoint_url = press_settings.remote_uploads_endpoint
region_name = press_settings.remote_uploads_region
aws_access_key_id = press_settings.offsite_backups_access_key_id
aws_secret_access_key = press_settings.get_password(

Check warning on line 286 in press/press/doctype/remote_file/remote_file.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/remote_file/remote_file.py#L277-L286

Added lines #L277 - L286 were not covered by tests
"offsite_backups_secret_access_key", raise_exception=False
)
else:
endpoint_url = frappe.db.get_value("Backup Bucket", bucket_name, "endpoint_url")
region_name = frappe.db.get_value("Backup Bucket", bucket_name, "region")
aws_access_key_id = press_settings.offsite_backups_access_key_id
aws_secret_access_key = press_settings.get_password(

Check warning on line 293 in press/press/doctype/remote_file/remote_file.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/remote_file/remote_file.py#L290-L293

Added lines #L290 - L293 were not covered by tests
"offsite_backups_secret_access_key", raise_exception=False
)

s3 = resource(
"s3",
aws_access_key_id=press_settings.offsite_backups_access_key_id,
aws_secret_access_key=press_settings.get_password(
"offsite_backups_secret_access_key", raise_exception=False
),
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
region_name=region_name or "ap-south-1",
endpoint_url=endpoint_url or "https://s3.amazonaws.com",
)
Expand Down

0 comments on commit 72b56a8

Please sign in to comment.