mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
fix(platforms): stop filing sgb folders as Game Boy Color (#5530)
* fix(platforms): stop filing sgb folders as Game Boy Color ES-DE and Batocera name their Super Game Boy system sgb (Game Boy games on the SNES adapter). Mapping sgb and sgb-msu1 to gbc gave those folders Game Boy Color provider ids and limited IGDB searches to the wrong platform. RomM has no Super Game Boy slug and IGDB, TheGamesDB, RetroAchievements and LaunchBox list none, so leave the folders unidentified; a config binding can still map them. Fixes #5506 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(scan): keep a missing platform folder unless its alias exists Addresses Greptile review on #5530: with the sgb aliases gone, gbc2players became the reverse folder for gbc, and a rescan with the gbc folder missing saved that nonexistent folder on the platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
b0de3f224c
commit
fa3654dd79
@@ -166,14 +166,13 @@ async def scan_platform(
|
||||
extra=LOGGER_MODULE_NAME,
|
||||
)
|
||||
platform = db_platform_handler.get_platform_by_fs_slug(fs_slug)
|
||||
if platform:
|
||||
known_fs_slug = resolve_fs_slug(platform.slug, cnfg)
|
||||
if known_fs_slug:
|
||||
# `resolve_fs_slug` answers with a lowercased config key, but
|
||||
# every path is built from the folder's own casing.
|
||||
platform_attrs["fs_slug"] = (
|
||||
resolve_fs_folder(known_fs_slug, fs_platforms) or known_fs_slug
|
||||
)
|
||||
known_fs_slug = platform and resolve_fs_slug(platform.slug, cnfg)
|
||||
# `resolve_fs_slug` answers with a lowercased config key, but every
|
||||
# path is built from the folder's own casing. A folder that isn't on
|
||||
# disk either would only overwrite the stored one.
|
||||
known_folder = known_fs_slug and resolve_fs_folder(known_fs_slug, fs_platforms)
|
||||
if known_folder:
|
||||
platform_attrs["fs_slug"] = known_folder
|
||||
|
||||
platform_attrs["slug"] = resolve_platform_slug(fs_slug, cnfg)
|
||||
|
||||
|
||||
@@ -79,6 +79,26 @@ async def test_scan_platform():
|
||||
assert platform.tgdb_id is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("fs_platforms", "expected_fs_slug"),
|
||||
[([], "gbc"), (["gbc2players"], "gbc2players")],
|
||||
)
|
||||
async def test_scan_platform_keeps_missing_folder_unless_alias_exists(
|
||||
fs_platforms: list[str], expected_fs_slug: str
|
||||
):
|
||||
make_platform("gbc")
|
||||
with patch.object(
|
||||
meta_igdb_handler,
|
||||
"get_platform_discovery",
|
||||
new_callable=AsyncMock,
|
||||
return_value={},
|
||||
):
|
||||
async with initialize_context():
|
||||
platform = await scan_platform("gbc", fs_platforms)
|
||||
|
||||
assert platform.fs_slug == expected_fs_slug
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
async def test_scan_rom():
|
||||
platform = make_platform("n64", id=1, name="Nintendo 64", igdb_id=4, hasheous_id=64)
|
||||
|
||||
@@ -66,6 +66,13 @@ def test_resolves_easyrpg_to_rpg_maker():
|
||||
assert resolve_fs_slug(UPS.RPG_MAKER.value, _config()) == "easyrpg"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("folder", ["sgb", "sgb-msu1"])
|
||||
def test_super_game_boy_folders_stay_unidentified(folder: str):
|
||||
"""ES-DE and Batocera use sgb for the Super Game Boy, which has no RomM slug."""
|
||||
assert resolve_builtin_platform_slug(folder) is None
|
||||
assert resolve_platform_slug(folder, _config()) == folder
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("folder", "slug"),
|
||||
[
|
||||
|
||||
@@ -115,8 +115,6 @@ PLATFORM_FS_ALIASES: Final[dict[str, UPS]] = {
|
||||
"segastv": UPS.STV,
|
||||
"sfc": UPS.SFAM,
|
||||
"sg-1000": UPS.SG1000,
|
||||
"sgb": UPS.GBC,
|
||||
"sgb-msu1": UPS.GBC,
|
||||
"snes-msu1": UPS.SNES,
|
||||
"sufami": UPS.SUFAMI_TURBO,
|
||||
"supracan": UPS.SUPER_ACAN,
|
||||
|
||||
Reference in New Issue
Block a user