mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-19 01:43:25 -05:00
fix: refuse to pack an archive that fails its CRC
The deterministic rebuild raises on a member whose bytes fail their CRC, and the builder caught it and copied the damaged archive into the pack, expecting verify to flag it, which nothing did. The run now stops on it and names the file to restore.
This commit is contained in:
1 parent
cc18b4f2d6
commit
baf635cf4e
2 files changed
+43
-4
No files matched your search
@@ -1217,6 +1217,10 @@ def _add_zip_to_pack(
|
||||
_normalize_zip_for_pack(source_zip, dest_path, target_zf)
|
||||
|
||||
|
||||
class DamagedArchiveError(OSError):
|
||||
"""An archive of the collection whose members fail their own CRC."""
|
||||
|
||||
|
||||
def _normalize_zip_for_pack(
|
||||
source_zip: str, dest_path: str, target_zf: zipfile.ZipFile
|
||||
) -> None:
|
||||
@@ -1241,9 +1245,12 @@ def _normalize_zip_for_pack(
|
||||
try:
|
||||
rebuild_zip_deterministic(source_zip, tmp_path)
|
||||
_add_pack_member(target_zf, tmp_path, dest_path)
|
||||
except zipfile.BadZipFile:
|
||||
# Corrupt source ZIP: copy as-is (will be flagged by verify)
|
||||
_add_pack_member(target_zf, source_zip, dest_path)
|
||||
except zipfile.BadZipFile as exc:
|
||||
# The rebuild checks every member's CRC. Copied as-is "for verify to
|
||||
# flag", a damaged archive went into the pack and nothing flagged it.
|
||||
raise DamagedArchiveError(
|
||||
f"{source_zip}: {exc}; restore it from git or the release before packing"
|
||||
) from exc
|
||||
finally:
|
||||
os.unlink(tmp_path)
|
||||
|
||||
@@ -2847,7 +2854,13 @@ _MISSING_DATA_DIRS: set[str] = set()
|
||||
|
||||
def main() -> None:
|
||||
with contextlib.ExitStack() as held:
|
||||
_main(held)
|
||||
try:
|
||||
_main(held)
|
||||
except DamagedArchiveError as exc:
|
||||
# Emulator, system and hash modes have no per-platform loop to
|
||||
# report it: the run stops with the file to restore.
|
||||
print(f"ERROR: {exc}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if _MISSING_DATA_DIRS:
|
||||
print(
|
||||
"ERROR: packs written without data directories that are not cached: "
|
||||
|
||||
Reference in new issue
Block a user