Fix ES-DE multi-folder exclusion matching

Agent-Logs-Url: https://github.com/rommapp/romm/sessions/2213cb94-9971-48a6-8d17-9efc5c209db4

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-05-21 11:22:21 +00:00
committed by GitHub
parent fbd086f487
commit 9e3f85b085
2 changed files with 33 additions and 2 deletions

View File

@@ -374,10 +374,17 @@ class FSRomsHandler(FSHandler):
def exclude_multi_roms(self, roms: list[str]) -> list[str]:
excluded_names = cm.get_config().EXCLUDED_MULTI_FILES
filtered_files: list = []
normalized_excluded = {
excluded_name.strip().lower() for excluded_name in excluded_names
}
filtered_files: list[str] = []
for rom in roms:
if rom in excluded_names:
normalized_rom_name = rom.strip().lower()
if normalized_rom_name in normalized_excluded or any(
fnmatch.fnmatch(normalized_rom_name, exc_name.strip().lower())
for exc_name in excluded_names
):
filtered_files.append(rom)
return [f for f in roms if f not in filtered_files]

View File

@@ -249,6 +249,30 @@ class TestFSRomsHandler:
result = handler.exclude_multi_roms(roms)
assert result == roms
def test_exclude_multi_roms_case_insensitive(self, handler: FSRomsHandler, config):
"""Test exclude_multi_roms ignores case in excluded names"""
roms = ["Game1", "Manuals", "Game2"]
config.EXCLUDED_MULTI_FILES = ["manuals"]
with pytest.MonkeyPatch.context() as m:
m.setattr("handler.filesystem.roms_handler.cm.get_config", lambda: config)
result = handler.exclude_multi_roms(roms)
assert result == ["Game1", "Game2"]
def test_exclude_multi_roms_ignores_whitespace(
self, handler: FSRomsHandler, config
):
"""Test exclude_multi_roms trims accidental surrounding whitespace"""
roms = ["Game1", "covers", "Game2"]
config.EXCLUDED_MULTI_FILES = [" covers "]
with pytest.MonkeyPatch.context() as m:
m.setattr("handler.filesystem.roms_handler.cm.get_config", lambda: config)
result = handler.exclude_multi_roms(roms)
assert result == ["Game1", "Game2"]
def test_build_rom_file_single_file(self, rom_single: Rom, handler: FSRomsHandler):
"""Test _build_rom_file with actual single ROM file"""
rom_path = Path(rom_single.fs_path)