From 6c7f1c9d06a2c4b816a8fa8d2792653d541eec3b Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 18 Oct 2026 19:49:17 +0200 Subject: [PATCH] fix: let a lone core file leave its system's drop --- scripts/packextras.py | 5 +++-- scripts/region.py | 14 +++++++++++++- tests/test_region.py | 12 ++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/scripts/packextras.py b/scripts/packextras.py index 0576cf3f..72b85cb2 100644 --- a/scripts/packextras.py +++ b/scripts/packextras.py @@ -20,6 +20,7 @@ from common import standalone_set as platform_standalone_set from common import sanitize_pack_path from common import size_fits from validation import read_from_system_dir +from region import FILE_GROUP def _detect_extras_prefix(config: dict, base_dest: str) -> str: @@ -1044,7 +1045,7 @@ def extra_region_groups( # Enterprise group drop its German ROM. Alone, it drops nothing and is # never dropped. destination = extra.get("destination", extra.get("name", "")) - return [f"{emulator}:file:{destination}"] + return [f"{emulator}{FILE_GROUP}{destination}"] def emulator_region_drops( selected: list[tuple[str, dict]], @@ -1108,5 +1109,5 @@ def _emulator_region_group( if not system and len(profile_systems) == 1: system = profile_systems[0] if not system: - return f"{emu_name}:file:{dest}" + return f"{emu_name}{FILE_GROUP}{dest}" return f"{emu_name}:system:{system}" diff --git a/scripts/region.py b/scripts/region.py index f2a659aa..94ee061e 100644 --- a/scripts/region.py +++ b/scripts/region.py @@ -266,6 +266,11 @@ def _competing_ranks( return ranked +# Marks the group of a file no system names (extra_region_groups and the +# emulator-mode grouping both build it). +FILE_GROUP = ":file:" + + def resolve_region_drops( groups: dict[str, list[tuple[str, str]]], index: dict[str, dict], @@ -288,7 +293,14 @@ def resolve_region_drops( keep: set[str] = set() drop: set[str] = set() - for members in groups.values(): + for group_id, members in groups.items(): + if FILE_GROUP in group_id: + # A file no system names competes with nothing: it drops nothing, + # and keeping it would veto the group that does decide for the + # same path. Dolphin's GC/EUR/IPL.bin, alone as a core extra, + # kept what the GameCube group dropped for --region us. A system + # holding one file still keeps it: a group is never emptied. + continue regional: list[tuple[int, str]] = [] world: set[str] = set() untagged: set[str] = set() diff --git a/tests/test_region.py b/tests/test_region.py index eeedeb4c..f5c9662b 100644 --- a/tests/test_region.py +++ b/tests/test_region.py @@ -267,6 +267,18 @@ class TestResolveRegionDrops(unittest.TestCase): def _drops(self, groups, requested): return region.resolve_region_drops(groups, self.index, requested) + def test_a_lone_file_never_vetoes_its_system(self): + """Dolphin's GC/EUR/IPL.bin came back as a core extra alone in its + group, and that group's keep cancelled the drop the GameCube group + decided: the full pack kept what --source platform dropped.""" + groups = { + "psx": [("scph5501.bin", "scph5501.bin"), ("scph5502.bin", "scph5502.bin")], + "core:file:scph5502.bin": [("scph5502.bin", "scph5502.bin")], + } + self.assertEqual(self._drops(groups, ["north-america"]), {"scph5502.bin"}) + alone = {"core:file:scph5502.bin": [("scph5502.bin", "scph5502.bin")]} + self.assertEqual(self._drops(alone, ["north-america"]), set()) + def test_a_missing_match_never_displaces_a_held_file(self): """Grouped so the report can withdraw it, a missing file must not take a held one's place: a Japanese request with only the American