Fix download sources on SIG branches

This commit is contained in:
Troy Dawson 2022-10-10 15:04:15 -07:00 committed by tdawson
parent e1698bf664
commit 70ef295451

View file

@ -207,32 +207,31 @@ class SIGLookasideCache(CGILookasideCache):
It inherits most of its behavior from `pyrpkg.lookasideCGILookasideCache`.
"""
def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash'):
def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash', client_cert=None, ca_cert=None):
super(SIGLookasideCache, self).__init__(
hashtype, download_url, upload_url,
client_cert=client_cert, ca_cert=ca_cert)
hashtype, download_url, upload_url, client_cert=client_cert, ca_cert=ca_cert)
self.name = name
self.branch = branch
self.structure = structure
@property
def download_path(self):
if self.structure == 'hash':
return '%(name)s/%(filename)s/%(hashtype)s/%(hash)s'
return '%(name)s/%(branch)s/%(hash)s'
def get_download_url(self, name, filename, hash, hashtype=None, **kwargs):
if self.structure == 'hash':
download_path = '%(name)s/%(branch)s/%(hash)s'
if "/" in name:
real_name = name.split("/")[-1]
else:
real_name = name
path_dict = {
'name': name,
'filename': filename,
'hash': hash,
'hashtype': hashtype
'name': real_name,
'filename': filename,
'branch': self.branch,
'hash': hash,
'hashtype': hashtype
}
path = self.download_path % path_dict
path = download_path % path_dict
return os.path.join(self.download_url, path)
return super(SIGLookasideCache, self).get_download_url(name, filename, hash, hashtype, **kwargs)
def remote_file_exists(self, name, filename, hash):