mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-04-13 12:22:33 -05:00
fix: resolve_file prefers primary over variants for name fallback
When resolving by name with no MD5 (existence check), prefer files NOT in .variants/ directory. Fixes naomi2.zip resolving to the Recalbox variant (15 files) instead of the primary (21 files). Also applies to hash_mismatch fallback path.
This commit is contained in:
@@ -155,19 +155,27 @@ def resolve_file(file_entry: dict, db: dict, bios_dir: str,
|
||||
# No MD5 specified = any local file with that name is acceptable
|
||||
if not md5:
|
||||
name_matches = db.get("indexes", {}).get("by_name", {}).get(name, [])
|
||||
candidates = []
|
||||
for match_sha1 in name_matches:
|
||||
if match_sha1 in db["files"]:
|
||||
local_path = db["files"][match_sha1]["path"]
|
||||
if os.path.exists(local_path):
|
||||
return local_path, "exact"
|
||||
candidates.append(local_path)
|
||||
if candidates:
|
||||
primary = [p for p in candidates if "/.variants/" not in p]
|
||||
return (primary[0] if primary else candidates[0]), "exact"
|
||||
|
||||
# Name fallback (hash mismatch)
|
||||
# Name fallback (hash mismatch) - prefer primary over variants
|
||||
name_matches = db.get("indexes", {}).get("by_name", {}).get(name, [])
|
||||
candidates = []
|
||||
for match_sha1 in name_matches:
|
||||
if match_sha1 in db["files"]:
|
||||
local_path = db["files"][match_sha1]["path"]
|
||||
if os.path.exists(local_path):
|
||||
return local_path, "hash_mismatch"
|
||||
candidates.append(local_path)
|
||||
if candidates:
|
||||
primary = [p for p in candidates if "/.variants/" not in p]
|
||||
return (primary[0] if primary else candidates[0]), "hash_mismatch"
|
||||
|
||||
return None, "not_found"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user