fix: keep the agnostic scan inside its own tree

A filename-agnostic core accepts any name for its BIOS, so the builder
scans the directory holding the candidates. It picked that directory
from a first-hit lookup by name, the one piece of evidence that lands
in another emulator's tree: five files answer to GameIndex.yaml and one
belongs to an Android package, rom1.bin is a PS2 ROM and a Roland
SC-55 ROM. One wrong match became every file beside it, flattened into
the BIOS root of platforms that do not run that emulator: 45 files in
the Recalbox pack, 170 in the RetroArch one.

Four things decide it now. A destination and the repo layout meet on a
tail, so the path index is tried from the longest tail down and never
to the bare filename; that alone corrects seven files, among them the
Japanese GameCube slot, which held the US dump. A seed has to declare
the shape it is looking for, since no shape means the whole directory.
An ambiguous name needs the profile's other files to agree before the
scan walks anywhere. What the scan emits carries the SHA-1 it selected,
so packing never resolves it by name again.
This commit is contained in:
Abdessamad Derraz committed 2026-08-12 07:23:23 +02:00
1 parent b33d045175
commit b11c8b0638
3 files changed
+320 -37

No files matched your search

+17 -8
View File
@@ -664,15 +664,24 @@ def resolve_local_file(
# is identity evidence only when no content hash was declared. A stale
# or incorrect destination can therefore never mask a hash mismatch.
if dest_hint and by_path_suffix:
for match_sha1 in by_path_suffix.get(dest_hint, []):
if match_sha1 in files_db:
# A destination is written from the emulator's point of view
# ("pcsx2/resources/GameIndex.yaml") and the index from the repo's
# layout, so the two meet on a tail rather than on the whole string.
# Longest tail first, and never down to the bare filename: that is the
# weaker step below, and five files answer to GameIndex.yaml.
hint_parts = dest_hint.split("/")
for start in range(len(hint_parts) - 1):
for match_sha1 in by_path_suffix.get("/".join(hint_parts[start:]), []):
if match_sha1 not in files_db:
continue
path = files_db[match_sha1]["path"]
if os.path.exists(path):
if not has_strong_hash:
return path, "path_exact"
status = _record_match_status(match_sha1)
if status:
return path, status
if not os.path.exists(path):
continue
if not has_strong_hash:
return path, "path_exact"
status = _record_match_status(match_sha1)
if status:
return path, status
# 3. No MD5 = any file with that name or alias (existence check)
def _size_ok(match_sha1: str) -> bool: