From 4fec09a014217d037703c36df48f71f488ba7e24 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 21 Oct 2026 09:56:45 +0200 Subject: [PATCH] fix: name the selection mode in --from-md5 packs BizHawk is both a platform and a profile display name: --from-md5 with --platform bizhawk and with --emulator bizhawk wrote one file in two layouts. The emulator mode now carries _Emulator in the name. --- scripts/generate_pack.py | 8 +++++++- tests/test_e2e.py | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index dba57a5e..67e79315 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -2154,6 +2154,11 @@ def generate_md5_pack( plat_file_index.setdefault(alias.lower(), []).append(fe) context_name = plat_display if platform_name else (emu_display or "Custom") + # The selection mode is part of the name, as for --system: BizHawk is + # both a platform and a profile display name, and the two layouts + # (Firmware/ under the platform, the profile's paths under the core) + # wrote one file, the second run replacing the first without a word. + mode_part = "_Emulator" if emulator_name and not platform_name else "" # --standalone changes the destination layout, so a run with it must not # take the name of a run without it. custom_tags = "".join( @@ -2168,7 +2173,8 @@ def generate_md5_pack( "\n".join(sorted(f"{kind}:{value.lower()}" for kind, value in hashes)).encode() ).hexdigest()[:8] zip_name = ( - f"{_name_part(context_name, '_')}_Custom_{selection}{custom_tags}_BIOS_Pack.zip" + f"{_name_part(context_name, '_')}{mode_part}_Custom_{selection}{custom_tags}" + "_BIOS_Pack.zip" ) zip_path = os.path.join(output_dir, zip_name) os.makedirs(output_dir, exist_ok=True) diff --git a/tests/test_e2e.py b/tests/test_e2e.py index a169d30c..c08ab2da 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -2744,6 +2744,31 @@ class TestE2E(unittest.TestCase): self.assertIn("bios/scph5501.bin", names) self.assertIn("Custom", os.path.basename(zip_path)) + # A profile displayed under the platform's own name: BizHawk is + # both. The two layouts must not write one file. + emu_dir = os.path.join(tmpdir, "emulators-md5") + os.makedirs(emu_dir) + with open(os.path.join(emu_dir, "testplat.yml"), "w") as f: + yaml.dump({ + "emulator": "TestPlat", "type": "standalone", + "systems": ["sony-playstation"], + "files": [{"name": "scph5501.bin", "md5": h["md5"]}], + }, f) + emu_zip = generate_md5_pack( + hashes=[("md5", h["md5"])], + db=db, + bios_dir=bios_dir, + output_dir=out_dir, + zip_contents=zip_contents, + emulator_name="testplat", + emulators_dir=emu_dir, + ) + self.assertIsNotNone(emu_zip) + self.assertNotEqual(os.path.basename(emu_zip), os.path.basename(zip_path)) + self.assertTrue(os.path.exists(zip_path)) + with zipfile.ZipFile(emu_zip) as zf: + self.assertIn("scph5501.bin", zf.namelist()) + def test_143_from_md5_not_in_repo(self): """--from-md5 reports files in DB but missing from repo.""" import contextlib