From 046fb276b08c40248137d40cd8edbffc68cf3a82 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 18 Mar 2026 06:27:22 +0100 Subject: [PATCH] fix: case-insensitive MD5 lookup in resolve_file Recalbox uses uppercase MD5 hashes (6E3735FF...) but database index is lowercase. Added .lower() to MD5 lookups in resolve_file(). Fixes scph101.bin wrong variant in Recalbox pack (was picking .variants/ copy instead of primary due to MD5 case mismatch). --- scripts/generate_pack.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index cf638549..d46c0d9b 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -124,7 +124,7 @@ def resolve_file(file_entry: dict, db: dict, bios_dir: str, # Skip MD5 direct lookup for zipped_file entries: the md5 is for the inner ROM, # not the container ZIP. Matching it would resolve to the standalone ROM file. if md5 and not zipped_file: - sha1_from_md5 = db.get("indexes", {}).get("by_md5", {}).get(md5) + sha1_from_md5 = db.get("indexes", {}).get("by_md5", {}).get(md5.lower()) if sha1_from_md5 and sha1_from_md5 in db["files"]: local_path = db["files"][sha1_from_md5]["path"] if os.path.exists(local_path): @@ -132,8 +132,9 @@ def resolve_file(file_entry: dict, db: dict, bios_dir: str, # Truncated MD5 match (batocera-systems bug: 29 chars instead of 32) if len(md5) < 32: + md5_lower = md5.lower() for db_md5, db_sha1 in db.get("indexes", {}).get("by_md5", {}).items(): - if db_md5.startswith(md5) and db_sha1 in db["files"]: + if db_md5.startswith(md5_lower) and db_sha1 in db["files"]: local_path = db["files"][db_sha1]["path"] if os.path.exists(local_path): return local_path, "exact"