fix: check packs with the builder's own verdict

This commit is contained in:
Abdessamad Derraz committed 2026-10-17 01:44:38 +02:00
1 parent 5c969a3651
commit 20638fde93
3 files changed
+26 -24

No files matched your search

+6 -4
View File
@@ -17,7 +17,7 @@ from packpaths import _register_path
from ziptools import build_zip_contents_index
from ziptools import check_inside_zip
from nativemode import digest_algorithm
from validation import settle_mismatch
from validation import baseline_verdict
from nativemode import hash_mismatch_excludes_file
import functools
import hashlib
@@ -482,9 +482,11 @@ def _intentional_hash_exclusion(
data_dir_registry=data_dir_registry,
offline=True,
)
# The builder ships what the frontend would accept: the exact inner
# ROM of a zipped_file entry, or a file its own digest matches.
if settle_mismatch(entry, local_path, status, verification_mode) != "hash_mismatch":
# The builder's own verdict: a zipped_file archive is refused when the
# member is missing whatever the outer resolution said, a hash
# mismatch when the frontend's digest disagrees too.
_status, refusal = baseline_verdict(entry, local_path, status, verification_mode)
if refusal is None:
return False
return True
-20
View File
@@ -694,26 +694,6 @@ def inner_rom_check(file_entry: dict, local_path: str) -> str:
return result
def settle_mismatch(
file_entry: dict, local_path: str | None, status: str, verification_mode: str
) -> str:
"""Upgrade a hash mismatch the frontend itself would accept.
Batocera pins the md5 of a ROM inside the archive (zipped_file), and a
frontend that hashes one digest accepts a file whose other declared
hashes disagree.
"""
if status != "hash_mismatch" or not local_path:
return status
if file_entry.get("zipped_file"):
return "zip_exact" if inner_rom_check(file_entry, local_path) == "ok" else status
if hash_mismatch_excludes_file(verification_mode) and frontend_digest_matches(
file_entry, local_path, digest_algorithm(verification_mode)
):
return "frontend_digest_exact"
return status
def baseline_verdict(
file_entry: dict, local_path: str | None, status: str, verification_mode: str
) -> tuple[str, str | None]: