mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-23 20:29:06 -05:00
fix: settle round 3 checks across packages
This commit is contained in:
1 parent
f0e7d87def
commit
2a29ca309c
4 files changed
+18
-12
No files matched your search
@@ -14,23 +14,29 @@ from pathlib import Path
|
||||
API = "https://abdess.github.io/retrobios/api/v1/platforms/"
|
||||
|
||||
|
||||
# The digest each check mode compares. A mode missing here (existence) only
|
||||
# asks that the file be present.
|
||||
DIGESTS = {"md5": "md5", "sha1": "sha1"}
|
||||
|
||||
|
||||
def accepts(entry: dict, path: Path, mode: str) -> bool:
|
||||
"""Whether the platform's own check passes the file at path."""
|
||||
digest = DIGESTS.get(mode)
|
||||
raw = entry.get(mode) or ""
|
||||
values = raw if isinstance(raw, list) else str(raw).split(",")
|
||||
declared = [value.strip().lower() for value in values if value.strip()]
|
||||
if mode == "existence" or not declared:
|
||||
if digest is None or not declared:
|
||||
return path.is_file() # nothing to compare: the platform checks presence
|
||||
try:
|
||||
if entry.get("zipped_file"): # the hash of one member, its name casefolded
|
||||
with zipfile.ZipFile(path) as archive:
|
||||
names = {name.casefold(): name for name in archive.namelist()}
|
||||
member = names.get(entry["zipped_file"].casefold())
|
||||
return bool(member) and hashlib.new(mode, archive.read(member)).hexdigest() in declared
|
||||
actual = hashlib.new(mode, path.read_bytes()).hexdigest()
|
||||
return bool(member) and hashlib.new(digest, archive.read(member)).hexdigest() in declared
|
||||
actual = hashlib.new(digest, path.read_bytes()).hexdigest()
|
||||
if entry.get("zip_digest") != "composite" and any(actual.startswith(d) for d in declared):
|
||||
return True # a truncated md5 (Batocera) compares by its prefix
|
||||
if mode == "md5" and path.suffix.lower() == ".zip": # Recalbox: members in name order
|
||||
if digest == DIGESTS["md5"] and path.suffix.lower() == ".zip": # Recalbox: members in name order
|
||||
with zipfile.ZipFile(path) as archive:
|
||||
names = sorted(name for name in archive.namelist() if not name.endswith("/"))
|
||||
return hashlib.md5(b"".join(map(archive.read, names))).hexdigest() in declared
|
||||
|
||||
@@ -6100,7 +6100,6 @@ def _directory_copies(entry: dict, consumers: FileConsumers) -> list[str]:
|
||||
f"([browse]({tree}))"]
|
||||
|
||||
|
||||
ROMSET_FAQ = "../wiki/technical-faq.md#which-mame-version-do-the-arcade-bios-sets-match"
|
||||
_MAME_RELEASE = re.compile(r"^0\.\d")
|
||||
|
||||
|
||||
@@ -8473,7 +8472,7 @@ def generate_which_pack() -> str:
|
||||
*setup_picker(registry, display),
|
||||
"## Folders and ZIP files { #manual-download }",
|
||||
"",
|
||||
"- A big ZIP comes in parts. Download every part.",
|
||||
"- A big ZIP comes in parts, like `Pack.part1of2.zip`. Download every part.",
|
||||
"- Unzip them into your BIOS folder. Put the files straight in it, "
|
||||
"not in a new folder.",
|
||||
"- Leave the ZIPs inside, like `neogeo.zip`, as they are.",
|
||||
|
||||
Reference in new issue
Block a user