mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-27 20:08:51 -06:00
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:
1 parent
7cd499531d
commit
348d5b51c3
32 files changed
+130
-217
No files matched your search
@@ -17,7 +17,7 @@ from model.registry import load_data_dir_registry
|
||||
from resolve.standalone import platform_layouts, standalone_set as platform_standalone_set
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from model.alternatives import groups_of
|
||||
from core.hashing import compute_hashes
|
||||
from core.hashing import compute_hashes, parse_hash_list
|
||||
from resolve.validation import (
|
||||
filter_files_by_mode,
|
||||
installed_with_emulator,
|
||||
@@ -249,10 +249,8 @@ def _shares_hash(a: dict, b: dict) -> bool:
|
||||
|
||||
|
||||
def _declared(entry: dict, field: str) -> set[str]:
|
||||
"""The values an entry declares for a hash field, one or a list."""
|
||||
value = entry.get(field)
|
||||
values = value if isinstance(value, list) else [value]
|
||||
return {str(v).lower() for v in values if v}
|
||||
"""The values an entry declares for a hash field, one, a list or comma-joined."""
|
||||
return set(parse_hash_list(entry.get(field)))
|
||||
|
||||
|
||||
def _contents_disagree(a: dict, b: dict) -> bool:
|
||||
@@ -350,15 +348,15 @@ def _merge_hashes(
|
||||
existing[h] = theirs
|
||||
existing.setdefault("_hash_by", {})[h] = emu_name
|
||||
continue
|
||||
t_list = theirs if isinstance(theirs, list) else [theirs]
|
||||
o_list = ours if isinstance(ours, list) else [ours]
|
||||
# A field holds one value, a list or a comma-joined string (mesence
|
||||
# names twelve BS-X dumps in one sha256): compared value by value.
|
||||
t_list, o_list = parse_hash_list(theirs), parse_hash_list(ours)
|
||||
if revision:
|
||||
known = {str(v).lower() for v in o_list}
|
||||
added = [v for v in t_list if str(v).lower() not in known]
|
||||
added = [v for v in t_list if v not in o_list]
|
||||
if added:
|
||||
existing[h] = [*o_list, *added]
|
||||
continue
|
||||
if not {str(v).lower() for v in t_list} & {str(v).lower() for v in o_list}:
|
||||
if not set(t_list) & set(o_list):
|
||||
# The value kept is one revision among those the cores accept:
|
||||
# it pairs an entry, it never overrules one (checked_hashes).
|
||||
existing["hash_conflict"] = sorted({*existing.get("hash_conflict", ()), h})
|
||||
|
||||
Reference in new issue
Block a user