refactor: read md5 lists through parse_hash_list

The RetroDECK and Recalbox exporters compare md5 lists with
resolve.reconcile.hash_values, and the RetroDECK scraper reads an entry's
md5 with md5_field and parse_hash_list instead of its own copy.

Recalbox's comparison no longer keeps an empty item: md5="a,,b" states
a,b where it stated ,a,b. The RetroDECK scraper now splits a
comma-joined value and refuses an md5 that is neither a string nor a
list of strings, as the batocera-systems readers do. The ten cached
component manifests write neither form, so retrodeck.yml is unchanged.
This commit is contained in:
Abdessamad Derraz committed 2026-11-20 20:02:44 +01:00
1 parent e19025231e
commit f7c08a6ca3
5 files changed
+50 -20

No files matched your search

+4 -2
View File
@@ -24,7 +24,9 @@ from model.profiles import load_emulator_profiles
from model.safeparse import parse_untrusted_xml
from .base_exporter import BaseExporter
from resolve.reconcile import NativeFile, NativeSystem, Report, by_destination, by_name
from resolve.reconcile import (
NativeFile, NativeSystem, Report, by_destination, by_name, hash_values,
)
SOURCE_URL = (
"https://gitlab.com/recalbox/recalbox/-/raw/master/board/recalbox/fsoverlay"
@@ -81,7 +83,7 @@ def _stated(text: str) -> dict[str, str]:
# Recalbox accepts any digest of the list (Bios.cpp:109-130): the
# order is not content, and neogeo.zip's 24, reordered, were
# written again.
attrs["md5"] = ",".join(sorted({h.strip().lower() for h in attrs["md5"].split(",")}))
attrs["md5"] = ",".join(sorted(hash_values(attrs, "md5")))
return attrs
+3 -8
View File
@@ -13,7 +13,7 @@ import json
from collections import OrderedDict
from .base_exporter import BaseExporter
from resolve.reconcile import NativeFile, NativeSystem, Report
from resolve.reconcile import NativeFile, NativeSystem, Report, hash_values
COMPONENTS_REPO = "RetroDECK/components"
COMPONENTS_BRANCH = "main"
@@ -33,11 +33,6 @@ def _systems_of(entry: dict) -> list[str]:
return [str(declared)] if declared else []
def _md5_set(value: object) -> set[str]:
values = value if isinstance(value, list) else str(value or "").split(",")
return {str(m).strip().lower() for m in values if str(m).strip()}
def _paths_key(entry: dict) -> tuple[str, ...]:
"""Where an entry says the file goes: no paths is the BIOS root."""
paths = entry.get("paths")
@@ -255,7 +250,7 @@ class Exporter(BaseExporter[str]):
other_revision = (
keys
and seen_keys.get(keys[0], 0) > 1
and not _md5_set(entry.get("md5")) & _md5_set(by_key[keys[0]].get("md5"))
and not set(hash_values(entry, "md5")) & set(hash_values(by_key[keys[0]], "md5"))
)
if other_revision or not keys:
merged.append(OrderedDict(entry))
@@ -307,7 +302,7 @@ class Exporter(BaseExporter[str]):
for field in ("md5", "sha256"):
if field in cls.carries() and field not in own:
combined.pop(field, None)
if _md5_set(entry.get("md5")) == _md5_set(combined.get("md5")):
if set(hash_values(entry, "md5")) == set(hash_values(combined, "md5")):
# Their own spelling, and no key where they wrote none: an
# equal empty set wrote "md5": null 39 times.
if "md5" in entry: