fix: read the data directory before other casings

Widening the name step to every casing served blueMSX a different MSX2P.ROM dump while data/bluemsx held the one it ships.
This commit is contained in:
Abdessamad Derraz committed 2026-10-18 19:40:25 +02:00
1 parent c2e3d64343
commit e644463c17
2 files changed
+30 -3

No files matched your search

+10 -3
View File
@@ -1365,7 +1365,12 @@ def resolve_local_file(
):
candidates.append(path)
owners = _owner_tokens(file_entry)
if not candidates or all(_foreign_tree(p, owners) for p in candidates):
# Only another emulator's tree answers the exact casing: what it
# holds there says nothing about this entry's file.
exact_foreign = bool(candidates) and all(
_foreign_tree(p, owners) for p in candidates
)
if not candidates or exact_foreign:
# Case-insensitive fallback: upstream platforms disagree on
# casing (VEC_MineStorm.vec vs VEC_Minestorm.vec). Two casings
# can name two contents (FONT.ROM and font.rom), so this only
@@ -1403,8 +1408,10 @@ def resolve_local_file(
# and a data directory it reads may hold it. Dolphin got
# Dolphin-MMJR's codehandler.bin while data/dolphin-sys held
# its own; blueMSX got the 16 KB RS232.ROM once msx-emu's
# 8 KB copy was set aside, while data/bluemsx held its own.
if data_dir_registry and _foreign_tree(best, owners):
# 8 KB copy was set aside, while data/bluemsx held its own,
# and MSX2P.ROM of another dump once only msx-emu answered
# the exact casing.
if data_dir_registry and (exact_foreign or _foreign_tree(best, owners)):
hit, _mismatch = _resolve_in_data_dirs(
names_to_try, data_dir_registry,
functools.partial(
+20
View File
@@ -73,6 +73,26 @@ class ForeignTreeNames(unittest.TestCase):
self.assertEqual(status, "data_dir")
self.assertEqual(Path(path).stat().st_size, 64)
def test_a_casing_only_another_tree_holds_reads_the_data_directory(self):
"""MSX2P.rom: only msx-emu's tree had the exact casing, and widening
to every casing served Microsoft/MSX/MSX2P.ROM, another dump, while
data/bluemsx held the one blueMSX ships."""
self._hold("bios/Other/msx-emu/Machines/Shared Roms/MSX2P.rom", b"B" * 64)
self._hold("bios/Microsoft/MSX/MSX2P.ROM", b"O" * 64)
cache = self.root / "data" / "bluemsx"
(cache / "Machines" / "Shared Roms").mkdir(parents=True)
(cache / "Machines" / "Shared Roms" / "MSX2P.rom").write_bytes(b"B" * 64)
entry = {
"name": "MSX2P.rom", "path": "Machines/Shared Roms/MSX2P.rom",
"source_emulator": "bluemsx",
}
path, status = resolve_local_file(
entry, self.db,
data_dir_registry={"bluemsx": {"local_cache": str(cache)}},
)
self.assertEqual(status, "data_dir")
self.assertEqual(Path(path).read_bytes(), b"B" * 64)
if __name__ == "__main__":
unittest.main()