mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-25 10:58:52 -06:00
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:
1 parent
e19025231e
commit
f7c08a6ca3
5 files changed
+50
-20
No files matched your search
@@ -39,6 +39,8 @@ if not __package__:
|
||||
importlib.import_module("scraper")
|
||||
__package__ = "scraper"
|
||||
|
||||
from core.hashing import parse_hash_list
|
||||
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
@@ -48,6 +50,7 @@ from .base_scraper import (
|
||||
fetch_text,
|
||||
github_tree,
|
||||
json_object,
|
||||
md5_field,
|
||||
requirement_entry,
|
||||
)
|
||||
from .retrodeck_launchers import extract_launchers
|
||||
@@ -298,17 +301,18 @@ def _entry_folder(paths_raw: object) -> str | None:
|
||||
return resolved
|
||||
|
||||
|
||||
_MD5 = re.compile(r"[0-9a-f]{32}")
|
||||
|
||||
|
||||
def _entry_md5(md5_raw: object) -> str:
|
||||
"""MD5 handling: sanitize upstream errors."""
|
||||
if isinstance(md5_raw, list):
|
||||
parts = [str(m).strip().lower() for m in md5_raw if m]
|
||||
elif md5_raw:
|
||||
parts = [str(md5_raw).strip().lower()]
|
||||
else:
|
||||
parts = []
|
||||
# Keep only valid 32-char hex MD5 hashes
|
||||
valid = [p for p in parts if re.fullmatch(r"[0-9a-f]{32}", p)]
|
||||
return ",".join(valid)
|
||||
"""The valid md5 values of a manifest entry, comma-joined.
|
||||
|
||||
An entry writes one string or a list of strings, as a batocera-systems
|
||||
item does. A value that is not a 32-digit hex md5 is an upstream error
|
||||
and is left out.
|
||||
"""
|
||||
values, _listed = md5_field(md5_raw or None)
|
||||
return ",".join(m for m in parse_hash_list(values) if _MD5.fullmatch(m))
|
||||
|
||||
|
||||
def _entry_requirement(entry: dict, comp_key: str, default_system: object) -> BiosRequirement | None:
|
||||
|
||||
Reference in new issue
Block a user