From 9e3f85b085fa77ad35dc1301f945a975ceba3754 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 21 May 2026 11:22:21 +0000 Subject: [PATCH] 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> --- backend/handler/filesystem/roms_handler.py | 11 +++++++-- .../handler/filesystem/test_roms_handler.py | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/backend/handler/filesystem/roms_handler.py b/backend/handler/filesystem/roms_handler.py index defbbb4e3..9e3405b0b 100644 --- a/backend/handler/filesystem/roms_handler.py +++ b/backend/handler/filesystem/roms_handler.py @@ -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] diff --git a/backend/tests/handler/filesystem/test_roms_handler.py b/backend/tests/handler/filesystem/test_roms_handler.py index ba60b53ec..9454be309 100644 --- a/backend/tests/handler/filesystem/test_roms_handler.py +++ b/backend/tests/handler/filesystem/test_roms_handler.py @@ -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)