From 32be737fb5d0f79895915b0dc2f2418f3d77b31c Mon Sep 17 00:00:00 2001 From: sergturi Date: Oct 14 2020 20:05:53 +0000 Subject: Add hashtype to lookaside download path Fixes: #521 Merges: https://pagure.io/rpkg/pull-request/522 Signed-off-by: sergturi --- diff --git a/pyrpkg/lookaside.py b/pyrpkg/lookaside.py index 084afdd..f960908 100644 --- a/pyrpkg/lookaside.py +++ b/pyrpkg/lookaside.py @@ -54,7 +54,7 @@ class CGILookasideCache(object): self.log = logging.getLogger(__name__) - self.download_path = '%(name)s/%(filename)s/%(hash)s/%(filename)s' + self.download_path = '%(name)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s' def print_progress(self, to_download, downloaded, to_upload, uploaded): if not sys.stdout.isatty(): diff --git a/tests/test_lookaside.py b/tests/test_lookaside.py index 413d8f6..83b331b 100644 --- a/tests/test_lookaside.py +++ b/tests/test_lookaside.py @@ -96,10 +96,12 @@ class CGILookasideCacheTestCase(unittest.TestCase): name = 'pyrpkg' filename = 'pyrpkg-0.0.tar.xz' + hashtype = 'sha512' hash = hashlib.sha512(b'content').hexdigest() outfile = os.path.join(self.workdir, 'pyrpkg-0.0.tar.xz') - full_url = 'http://example.com/%s/%s/%s/%s' % (name, filename, hash, - filename) + full_url = 'http://example.com/%s/%s/%s/%s/%s' % (name, filename, + hashtype, hash, + filename) lc = CGILookasideCache('sha512', 'http://example.com', '_') lc.download(name, filename, hash, outfile, hashtype='sha512')