refactor: read declared hashes with one helper

core.hashing.declared_hash_lists gives an entry's declared values per
field in the order written, and declared_hashes builds its sets on it.
The gap page, the doubled-destination report and the file lookup used
their own copies of that reader. The wanted page keeps its filters on
top of it. sitegen.lookup.hash_pairs replaces sorted_hash_values for
the lookup, the data exports and the structured data. The one-field
aliases parse_md5_list and reconcile.hash_values are gone, and
model.profiles reads HASH_FIELDS instead of a fourth tuple.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 10:29:37 +01:00
1 parent ea68e85c06
commit 02969dda06
30 files changed
+176 -195

No files matched your search

+4 -4
View File
@@ -26,7 +26,7 @@ from resolve.archives import archive_members
from model.profiles import CONTENT_CHECKS, entry_system_ids, lists_files
from core.hashing import compute_hashes, parse_hash_list
from core.paths import BIOS_DIR, sanitize_pack_path
from core.hashing import lists_hashes, md5_composite, parse_md5_list
from core.hashing import lists_hashes, md5_composite
from resolve.nativemode import SIZE_AND_ANY_HASH, digest_algorithm, hash_mismatch_excludes_file
from core.ziptools import check_inside_zip, check_inside_zip_data
@@ -791,7 +791,7 @@ def _platform_accepted(file_entry: dict, platform_digest: str) -> set[str]:
"""The values of the digest the frontend compares that the entry declares."""
declared = file_entry.get(platform_digest) or ""
if platform_digest == "md5":
return set(parse_md5_list(declared))
return set(parse_hash_list(declared))
if isinstance(declared, str) and declared:
return {declared.lower()}
if isinstance(declared, list):
@@ -964,7 +964,7 @@ def digest_verdict(
if file_entry.get(field)
)
if algorithm == "md5":
declared = parse_md5_list(file_entry.get("md5"))
declared = parse_hash_list(file_entry.get("md5"))
else:
value = file_entry.get(algorithm)
values = value if isinstance(value, list) else [value]
@@ -1011,7 +1011,7 @@ def inner_rom_data_check(file_entry: dict, data: bytes) -> str:
def _first_accepted_md5(file_entry: dict, check: Callable[[str], str]) -> str:
# With no md5 declared, checkInsideZip still runs and needs the member.
result = "not_in_zip"
for candidate in parse_md5_list(file_entry.get("md5")) or [""]:
for candidate in parse_hash_list(file_entry.get("md5")) or [""]:
result = check(candidate)
if result == "ok":
break