Skip to content

Commit

Permalink
Merge pull request #272 from GSA/s3-delete-objects
Browse files Browse the repository at this point in the history
use s3 delete-object to avoid Content-MD5 error
  • Loading branch information
FuhuXia authored Sep 18, 2023
2 parents b47fc54 + 155a7c1 commit b3dc5ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions ckanext/geodatagov/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,11 @@ def upload_to_key(upload_str: str, filename_on_s3: str) -> None:


def delete_old_sitemaps():
objects_to_delete = S3.list_objects(Bucket=BUCKET_NAME, Prefix=PREFIX)
objects_to_delete = S3.list_objects_v2(Bucket=BUCKET_NAME, Prefix=PREFIX)

delete_keys = {'Objects': []}
delete_keys['Objects'] = [{'Key': k} for k in [obj['Key'] for obj in objects_to_delete.get('Contents', [])]]

S3.delete_objects(Bucket=BUCKET_NAME, Delete=delete_keys)
for object in objects_to_delete['Contents']:
log.info("Deleting {}.".format(object['Key']))
S3.delete_object(Bucket=BUCKET_NAME, Key=object['Key'])


def upload_sitemap_file(sitemap: list) -> None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="ckanext-geodatagov",
version="0.2.6",
version="0.2.7",
description="",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit b3dc5ac

Please sign in to comment.