1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-24 03:02:12 +01:00

Re-download file from API when hdrmd5 doesn't match

This commit is contained in:
Daniel Mach 2022-02-18 11:56:25 +01:00
parent d76ec31ef4
commit fd6634e320

View File

@ -223,7 +223,6 @@ class Fetcher:
if not i.name.startswith('container:') and i.pacsuffix != 'rpm':
continue
if i.hdrmd5:
from .util import packagequery
if i.name.startswith('container:'):
hdrmd5 = dgst(i.fullfilename)
else:
@ -255,6 +254,20 @@ class Fetcher:
prefix = '[%d/%d] ' % (done, needed)
self.fetch(i, prefix=prefix)
if not os.path.isfile(i.fullfilename):
# if the file wasn't downloaded and cannot be found on disk,
# mark it for downloading from the API
self.__add_cpio(i)
else:
# if the checksum of the downloaded package doesn't match,
# delete it and mark it for downloading from the API
hdrmd5 = packagequery.PackageQuery.queryhdrmd5(i.fullfilename)
if not hdrmd5 or hdrmd5 != i.hdrmd5:
print('%s/%s: attempting download from api, since the hdrmd5 did not match'
% (i.project, i.name))
os.unlink(i.fullfilename)
self.__add_cpio(i)
except KeyboardInterrupt:
print('Cancelled by user (ctrl-c)')
print('Exiting.')