refactor: read hashes and the registry one way

Hash fields go through core.hashing.parse_hash_list, which also splits comma-joined list items: the truth model compared a comma-joined sha256 list as one value. _registry.yml goes through load_platform_registry (required= where an absent file must stop the run), database.json through load_database, file and member digests through file_digest and stream_hashes. download.py and check_release read SHA256SUMS.txt with one parser: a sha256sum -b line matched nothing in download.py and the pack went unchecked.
This commit is contained in:
Abdessamad Derraz committed 2026-11-20 18:28:40 +01:00
1 parent 7cd499531d
commit 348d5b51c3
32 files changed
+130 -217

No files matched your search

+2 -12
View File
@@ -6,7 +6,7 @@ import os
import zlib
from dataclasses import dataclass, field
from core.hashing import compute_hashes, parse_md5_list
from core.hashing import compute_hashes, parse_hash_list, parse_md5_list
from core.ziptools import check_inside_zip
from resolve.localfile import resolve_local_file, variant_base_name
from resolve.packfiles import records_by_path, preferred_entries
@@ -123,17 +123,7 @@ def lists_hashes(entry: dict) -> bool:
def _declared_hashes(entry: dict, field_name: str) -> set[str]:
"""Hashes an entry accepts for one field, declared as a string or a list."""
value = entry.get(field_name)
values = value if isinstance(value, list) else [value]
# Recalbox writes its md5 list comma separated, and profiles do the
# same for sha256 (mesence names four BS-X dumps in one string).
return {
part.strip().lower()
for v in values
if v
for part in str(v).split(",")
if part.strip()
}
return set(parse_hash_list(entry.get(field_name)))
def _record_at(path: str, db: dict) -> dict | None: