Skip to content

Commit

Permalink
Merge pull request #60 from qld-gov-au/QOL-8405-replace-cache-on-update
Browse files Browse the repository at this point in the history
[QOL-8405] append ETag to unsigned URLs, #59
  • Loading branch information
ThrawnCA authored Nov 23, 2021
2 parents d5d6698 + c4c9d17 commit 3130c9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ckanext/s3filestore/tests/test_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from nose.tools import (assert_equal,
assert_true,
assert_false,
assert_in,
with_setup)

import ckanapi
Expand Down Expand Up @@ -250,6 +251,7 @@ def test_resource_url_unsigned_for_public_dataset(self):
url = uploader.get_signed_url_to_key(key)

assert_false(_is_presigned_url(url))
assert_in('ETag=', url)

@helpers.change_config('ckanext.s3filestore.acl', 'auto')
def test_resource_url_signed_for_private_dataset(self):
Expand All @@ -276,6 +278,7 @@ def test_making_dataset_private_updates_object_visibility(self):

url = uploader.get_signed_url_to_key(key)
assert_false(_is_presigned_url(url))
assert_in('ETag=', url)

helpers.call_action('package_patch',
context={'user': self.sysadmin['name']},
Expand Down Expand Up @@ -305,6 +308,7 @@ def test_making_dataset_public_updates_object_visibility(self):

url = uploader.get_signed_url_to_key(key)
assert_false(_is_presigned_url(url))
assert_in('ETag=', url)

def test_assembling_object_metadata_headers(self):
''' Tests that text fields from the package are passed to S3.
Expand Down
2 changes: 1 addition & 1 deletion ckanext/s3filestore/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def get_signed_url_to_key(self, key, extra_params={}):
url = URL_HOST.sub(self.download_proxy + '/', url, 1)

if is_public_read:
url = url.split('?')[0]
url = url.split('?')[0] + '?ETag=' + metadata['ETag']

self._cache_put(key, url)
return url
Expand Down

0 comments on commit 3130c9e

Please sign in to comment.