feat: follow mame clones in the gap analysis

This commit is contained in:
Abdessamad Derraz committed 2026-08-12 03:15:05 +02:00
1 parent b86a34933c
commit 7c043475cd
3 files changed
+57 -3

No files matched your search

+6 -3
View File
@@ -783,7 +783,7 @@ def resolve_local_file(
# MAME clone fallback: if a file was deduped, resolve via canonical
if _depth < 3 and not has_strong_hash:
clone_map = _get_mame_clone_map()
clone_map = get_mame_clone_map()
canonical = clone_map.get(name)
if canonical and canonical != name:
canonical_entry = {"name": canonical}
@@ -835,7 +835,10 @@ def resolve_local_file(
return "data_dir_hash_exact"
data_dir_mismatch: str | None = None
if data_dir_registry:
# Without a hash the cache walk matches on filename alone, which is the
# step an unsourceable entry has to skip: hiscore.dat names one file per
# driver set, so FBNeo's copy would answer for MAME's.
if data_dir_registry and (has_strong_hash or not unsourceable):
for _dd_key, dd_entry in data_dir_registry.items():
cache_dir = dd_entry.get("local_cache", "")
if not cache_dir or not os.path.isdir(cache_dir):
@@ -890,7 +893,7 @@ def resolve_local_file(
_mame_clone_map_cache: dict[str, str] | None = None
def _get_mame_clone_map() -> dict[str, str]:
def get_mame_clone_map() -> dict[str, str]:
"""Load and cache the MAME clone map (clone_name -> canonical_name)."""
global _mame_clone_map_cache
if _mame_clone_map_cache is not None:
+11
View File
@@ -20,6 +20,7 @@ from pathlib import Path
sys.path.insert(0, os.path.dirname(__file__))
from common import (
get_mame_clone_map,
list_registered_platforms,
load_database,
load_emulator_profiles,
@@ -157,6 +158,16 @@ def _resolve_source(
# bios/ via by_path_suffix (regional variants)
if by_path_suffix and fname in by_path_suffix:
return "bios"
# bios/ under the canonical MAME set name, as resolve_local_file does:
# a renamed archive is held once, under the name the dedup kept.
canonical = get_mame_clone_map().get(fname)
if canonical and canonical != fname:
if canonical in by_name and _name_hit(canonical):
return "bios"
if canonical.lower() in by_name_lower and _name_hit(
by_name_lower[canonical.lower()]
):
return "bios"
# data/ supplemental index
if data_names:
if fname in data_names or key in data_names: