skip invalid package index files (tuna/issues#844)

This commit is contained in:
z4yx 2020-06-24 20:30:05 +08:00
parent 8337721aee
commit 924403f204

View File

@ -150,11 +150,13 @@ def apt_mirror(base_url: str, dist: str, repo: str, arch: str, dest_base_dir: Pa
with pkgidx_file.open('rb') as t: content = t.read() with pkgidx_file.open('rb') as t: content = t.read()
if len(content) != int(filesize): if len(content) != int(filesize):
print(f"Invalid size of {pkgidx_file}, expected {filesize}") print(f"Invalid size of {pkgidx_file}, expected {filesize}, skipped")
return 1 pkgidx_file.unlink()
continue
if hashlib.sha256(content).hexdigest() != checksum: if hashlib.sha256(content).hexdigest() != checksum:
print(f"Invalid checksum of {pkgidx_file}, expected {checksum}") print(f"Invalid checksum of {pkgidx_file}, expected {checksum}, skipped")
return 1 pkgidx_file.unlink()
continue
if pkgidx_content is None and pkgidx_file.stem == 'Packages': if pkgidx_content is None and pkgidx_file.stem == 'Packages':
print(f"getting packages index content from {pkgidx_file.name}", flush=True) print(f"getting packages index content from {pkgidx_file.name}", flush=True)
suffix = pkgidx_file.suffix suffix = pkgidx_file.suffix