mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 10:03:49 -06:00
fix: count name holders with case folded
A hashless profile entry adopted the only exact holder of its name as the file its aliases designate. dosbox's SC-55 ROM2.BIN found Galaksija's ROM2.BIN, and ROM2_ST.BIN was indexed against a 4 KiB BASIC ROM while SC-55's rom2.bin sat under the same folded name. The name now has to designate one file once case is folded, a primary and its own variants counted as one.
This commit is contained in:
1 parent
6695efeebe
commit
7a03578dd9
3 files changed
+43
-8
No files matched your search
+1
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"schema_version": 1,
|
"schema_version": 1,
|
||||||
"generated_at": "2026-11-05T23:59:37Z",
|
"generated_at": "2026-11-06T07:21:27Z",
|
||||||
"total_files": 19947,
|
"total_files": 19947,
|
||||||
"total_size": 16926035621,
|
"total_size": 16926035621,
|
||||||
"bios_dir": "bios",
|
"bios_dir": "bios",
|
||||||
@@ -281813,9 +281813,6 @@
|
|||||||
"TRIO64 (Ver. 1.5-07) [VGA] (S3 Incorporated).bin": [
|
"TRIO64 (Ver. 1.5-07) [VGA] (S3 Incorporated).bin": [
|
||||||
"a308b15f93da34961c0141ec95b98c211557e2d5"
|
"a308b15f93da34961c0141ec95b98c211557e2d5"
|
||||||
],
|
],
|
||||||
"ROM2_ST.BIN": [
|
|
||||||
"5d5ab4313a2d0effe7572bb129193b64cab002c1"
|
|
||||||
],
|
|
||||||
"mt32_ctrl_1_04.rom": [
|
"mt32_ctrl_1_04.rom": [
|
||||||
"5a5cb5a77d7d55ee69657c2f870416daed52dea7"
|
"5a5cb5a77d7d55ee69657c2f870416daed52dea7"
|
||||||
],
|
],
|
||||||
|
|||||||
+23
-4
@@ -576,12 +576,26 @@ def _collect_all_aliases(
|
|||||||
# naming its content once 64DD_IPL.bin sorted first, and its aliases
|
# naming its content once 64DD_IPL.bin sorted first, and its aliases
|
||||||
# 64dd_ipl_J.bin and 64DD_IPL_JP.n64 went with it.
|
# 64dd_ipl_J.bin and 64DD_IPL_JP.n64 went with it.
|
||||||
holders: dict[str, set[str]] = {}
|
holders: dict[str, set[str]] = {}
|
||||||
|
# The files a name designates once case is folded, as the resolver's
|
||||||
|
# name step folds it, a primary and its own .variants/ counted as one
|
||||||
|
# file. dosbox's SC-55 ROM2.BIN found Galaksija's ROM2.BIN the only
|
||||||
|
# exact holder, and its alias ROM2_ST.BIN went to a 4 KiB BASIC ROM,
|
||||||
|
# while SC-55's rom2.bin sat under the same folded name.
|
||||||
|
families: dict[str, set[str]] = {}
|
||||||
|
|
||||||
|
def _hold(name: str, path: str, sha1: str) -> None:
|
||||||
|
holders.setdefault(name, set()).add(sha1)
|
||||||
|
directory = path.rpartition("/")[0].removesuffix("/.variants")
|
||||||
|
families.setdefault(name.casefold(), set()).add(
|
||||||
|
f"{directory}/{variant_base_name(name)}".casefold()
|
||||||
|
)
|
||||||
|
|
||||||
for sha1, entry in files.items():
|
for sha1, entry in files.items():
|
||||||
holders.setdefault(entry["name"], set()).add(sha1)
|
_hold(entry["name"], entry["path"], sha1)
|
||||||
for sha1, copy_list in (copies or {}).items():
|
for sha1, copy_list in (copies or {}).items():
|
||||||
if sha1 in files:
|
if sha1 in files:
|
||||||
for copy in copy_list:
|
for copy in copy_list:
|
||||||
holders.setdefault(copy["name"], set()).add(sha1)
|
_hold(copy["name"], copy["path"], sha1)
|
||||||
|
|
||||||
aliases = {}
|
aliases = {}
|
||||||
|
|
||||||
@@ -691,11 +705,16 @@ def _collect_all_aliases(
|
|||||||
]
|
]
|
||||||
if taken:
|
if taken:
|
||||||
shadowed.append((entry_name, set(matched), taken))
|
shadowed.append((entry_name, set(matched), taken))
|
||||||
if not matched and len(holders.get(entry_name, ())) == 1:
|
held = holders.get(entry_name, set())
|
||||||
|
if (
|
||||||
|
not matched
|
||||||
|
and len(held) == 1
|
||||||
|
and len(families[entry_name.casefold()]) == 1
|
||||||
|
):
|
||||||
# A name carried by several contents names none of them:
|
# A name carried by several contents names none of them:
|
||||||
# quasi88's disk.rom aliases went to whichever
|
# quasi88's disk.rom aliases went to whichever
|
||||||
# disk.rom the scan met last, a Tandy CoCo ROM.
|
# disk.rom the scan met last, a Tandy CoCo ROM.
|
||||||
matched = set(holders[entry_name])
|
matched = set(held)
|
||||||
for sha in sorted(matched):
|
for sha in sorted(matched):
|
||||||
for alias_name in entry_aliases:
|
for alias_name in entry_aliases:
|
||||||
_add_alias(alias_name, sha)
|
_add_alias(alias_name, sha)
|
||||||
|
|||||||
@@ -56,6 +56,25 @@ class AliasesNeedAnUnambiguousName(unittest.TestCase):
|
|||||||
named = {a["name"] for entries in aliases.values() for a in entries}
|
named = {a["name"] for entries in aliases.values() for a in entries}
|
||||||
self.assertNotIn("n88sub.rom", named)
|
self.assertNotIn("n88sub.rom", named)
|
||||||
|
|
||||||
|
def test_homonyms_differing_in_case_take_no_alias(self):
|
||||||
|
"""dosbox's SC-55 ROM2.BIN: Galaksija's ROM2.BIN was the only exact
|
||||||
|
holder, and ROM2_ST.BIN went to it beside SC-55's rom2.bin."""
|
||||||
|
files = {
|
||||||
|
"a": self._file("DISK.ROM", "bios/NEC/PC-98/DISK.ROM", "m1"),
|
||||||
|
"b": self._file("disk.rom", "bios/Tandy/CoCo/disk.rom", "m2"),
|
||||||
|
}
|
||||||
|
aliases = self._aliases(files)
|
||||||
|
named = {a["name"] for entries in aliases.values() for a in entries}
|
||||||
|
self.assertNotIn("n88sub.rom", named)
|
||||||
|
|
||||||
|
def test_a_primary_and_its_variant_are_one_file(self):
|
||||||
|
files = {
|
||||||
|
"a": self._file("disk.rom", "bios/NEC/PC-88/disk.rom", "m1"),
|
||||||
|
"b": self._file("DISK.ROM", "bios/NEC/PC-88/.variants/DISK.ROM.0123abcd", "m2"),
|
||||||
|
}
|
||||||
|
aliases = self._aliases(files)
|
||||||
|
self.assertEqual([a["name"] for a in aliases.get("a", [])], ["n88sub.rom"])
|
||||||
|
|
||||||
def test_a_unique_name_still_carries_its_aliases(self):
|
def test_a_unique_name_still_carries_its_aliases(self):
|
||||||
files = {"a": self._file("disk.rom", "bios/NEC/PC-88/disk.rom", "m1")}
|
files = {"a": self._file("disk.rom", "bios/NEC/PC-88/disk.rom", "m1")}
|
||||||
aliases = self._aliases(files)
|
aliases = self._aliases(files)
|
||||||
|
|||||||
Reference in new issue
Block a user