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 -13
View File
@@ -15,7 +15,7 @@ import zipfile
from pathlib import Path
from model.largefiles import fetch_large_file
from core.hashing import cut_md5_owner
from core.hashing import cut_md5_owner, parse_hash_list
from resolve.content import declared_hash_verdict
from resolve.localfile import resolution_is_hash_exact, resolve_local_file
from core.paths import REPO_ROOT, declared_destination
@@ -84,20 +84,9 @@ def download_external(
return False
return True
def _values(raw: object) -> list[str]:
"""A hash field's values: one, a list, or a comma-separated string."""
items = raw if isinstance(raw, list) else [raw] if raw else []
return [
value.strip().lower().removeprefix("0x")
for item in items
for value in str(item).split(",")
if value.strip()
]
def _declared_hashes(file_entry: dict) -> dict[str, list[str]]:
return {
field: _values(file_entry.get(field))
field: parse_hash_list(file_entry.get(field))
for field in ("sha1", "md5", "sha256", "crc32")
}