From ca4e6d28b4fa6fa0498b1913b925f1a2efe8494e Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Fri, 4 Sep 2026 10:24:15 -0500 Subject: [PATCH] fix(config): keep scraper media folders out of platform exclusion DEFAULT_EXCLUDED_DIRS feeds both EXCLUDED_PLATFORMS and EXCLUDED_MULTI_FILES, so listing the gamelist media folders there also hid any platform directory that happened to share a name. The media folders now live in DEFAULT_EXCLUDED_MEDIA_DIRS and only join the multi-file exclusions. The config response exposes the new list so the settings UI keeps treating those entries as read-only defaults instead of offering a remove action that the next config load would undo. Co-Authored-By: Claude Fable 5.1 --- backend/config/config_manager.py | 5 ++-- backend/endpoints/configs.py | 2 ++ backend/endpoints/responses/config.py | 1 + backend/tests/config/test_config_loader.py | 6 +++- backend/tests/endpoints/test_config.py | 8 ++++- .../__generated__/models/ConfigResponse.ts | 1 + frontend/src/stores/config.ts | 1 + .../components/Settings/ExcludedSection.vue | 29 +++++++++++-------- 8 files changed, 37 insertions(+), 16 deletions(-) diff --git a/backend/config/config_manager.py b/backend/config/config_manager.py index 542c1d1bd..f922fe212 100644 --- a/backend/config/config_manager.py +++ b/backend/config/config_manager.py @@ -71,8 +71,6 @@ GAMELIST_MEDIA_DIRS: Final[dict[str, str]] = { DEFAULT_EXCLUDED_DIRS: Final = [ "@eaDir", "assets", - *GAMELIST_MEDIA_DIRS.values(), - "images", "__MACOSX", "#recycle", "$RECYCLE.BIN", @@ -83,6 +81,8 @@ DEFAULT_EXCLUDED_DIRS: Final = [ ".DocumentRevisions-V100", "System Volume Information", ] +# Scrapers write these beside the ROMs, so they are never multi-file ROMs. +DEFAULT_EXCLUDED_MEDIA_DIRS: Final = [*GAMELIST_MEDIA_DIRS.values(), "images"] class EjsControlsButton(TypedDict): @@ -423,6 +423,7 @@ class ConfigManager: EXCLUDED_MULTI_FILES=sorted( { *DEFAULT_EXCLUDED_DIRS, + *DEFAULT_EXCLUDED_MEDIA_DIRS, *pydash.get( self._raw_config, "exclude.roms.multi_file.names", diff --git a/backend/endpoints/configs.py b/backend/endpoints/configs.py index 54dd991f8..12429ba08 100644 --- a/backend/endpoints/configs.py +++ b/backend/endpoints/configs.py @@ -5,6 +5,7 @@ from config.config_manager import ( DEFAULT_EXCLUDED_DIRS, DEFAULT_EXCLUDED_EXTENSIONS, DEFAULT_EXCLUDED_FILES, + DEFAULT_EXCLUDED_MEDIA_DIRS, VALID_GAMELIST_IMAGE_TYPES, VALID_GAMELIST_THUMBNAIL_TYPES, VALID_SCAN_PRIORITY_SOURCES, @@ -125,6 +126,7 @@ def get_config(request: Request) -> ConfigResponse: EXCLUDED_MULTI_PARTS_EXT=cfg.EXCLUDED_MULTI_PARTS_EXT, EXCLUDED_MULTI_PARTS_FILES=cfg.EXCLUDED_MULTI_PARTS_FILES, DEFAULT_EXCLUDED_DIRS=list(DEFAULT_EXCLUDED_DIRS), + DEFAULT_EXCLUDED_MEDIA_DIRS=list(DEFAULT_EXCLUDED_MEDIA_DIRS), DEFAULT_EXCLUDED_FILES=list(DEFAULT_EXCLUDED_FILES), DEFAULT_EXCLUDED_EXTENSIONS=list(DEFAULT_EXCLUDED_EXTENSIONS), PLATFORMS_BINDING=cfg.PLATFORMS_BINDING, diff --git a/backend/endpoints/responses/config.py b/backend/endpoints/responses/config.py index e42b59669..09c666b0a 100644 --- a/backend/endpoints/responses/config.py +++ b/backend/endpoints/responses/config.py @@ -14,6 +14,7 @@ class ConfigResponse(TypedDict): EXCLUDED_MULTI_PARTS_EXT: list[str] EXCLUDED_MULTI_PARTS_FILES: list[str] DEFAULT_EXCLUDED_DIRS: list[str] + DEFAULT_EXCLUDED_MEDIA_DIRS: list[str] DEFAULT_EXCLUDED_FILES: list[str] DEFAULT_EXCLUDED_EXTENSIONS: list[str] PLATFORMS_BINDING: dict[str, str] diff --git a/backend/tests/config/test_config_loader.py b/backend/tests/config/test_config_loader.py index c460a952f..63f9b2232 100644 --- a/backend/tests/config/test_config_loader.py +++ b/backend/tests/config/test_config_loader.py @@ -5,6 +5,7 @@ from config.config_manager import ( DEFAULT_EXCLUDED_DIRS, DEFAULT_EXCLUDED_EXTENSIONS, DEFAULT_EXCLUDED_FILES, + DEFAULT_EXCLUDED_MEDIA_DIRS, ConfigManager, ) @@ -27,6 +28,7 @@ def test_config_loader(): assert loader.config.EXCLUDED_MULTI_FILES == sorted( { *DEFAULT_EXCLUDED_DIRS, + *DEFAULT_EXCLUDED_MEDIA_DIRS, "my_multi_file_game", "DLC", } @@ -108,7 +110,9 @@ def test_empty_config_loader(): ) assert "ini" not in loader.config.EXCLUDED_SINGLE_EXT assert loader.config.EXCLUDED_SINGLE_FILES == sorted(DEFAULT_EXCLUDED_FILES) - assert loader.config.EXCLUDED_MULTI_FILES == sorted(DEFAULT_EXCLUDED_DIRS) + assert loader.config.EXCLUDED_MULTI_FILES == sorted( + {*DEFAULT_EXCLUDED_DIRS, *DEFAULT_EXCLUDED_MEDIA_DIRS} + ) assert loader.config.EXCLUDED_MULTI_PARTS_EXT == sorted( {e.lower() for e in DEFAULT_EXCLUDED_EXTENSIONS} ) diff --git a/backend/tests/endpoints/test_config.py b/backend/tests/endpoints/test_config.py index b72b58938..cad774dbd 100644 --- a/backend/tests/endpoints/test_config.py +++ b/backend/tests/endpoints/test_config.py @@ -6,6 +6,7 @@ from config.config_manager import ( DEFAULT_EXCLUDED_DIRS, DEFAULT_EXCLUDED_EXTENSIONS, DEFAULT_EXCLUDED_FILES, + DEFAULT_EXCLUDED_MEDIA_DIRS, ) from config.config_manager import config_manager as cm @@ -20,11 +21,16 @@ def test_config(client): e.lower() for e in DEFAULT_EXCLUDED_EXTENSIONS ) assert config.get("EXCLUDED_SINGLE_FILES") == sorted(DEFAULT_EXCLUDED_FILES) - assert config.get("EXCLUDED_MULTI_FILES") == sorted(DEFAULT_EXCLUDED_DIRS) + assert config.get("EXCLUDED_MULTI_FILES") == sorted( + {*DEFAULT_EXCLUDED_DIRS, *DEFAULT_EXCLUDED_MEDIA_DIRS} + ) assert config.get("EXCLUDED_MULTI_PARTS_EXT") == sorted( e.lower() for e in DEFAULT_EXCLUDED_EXTENSIONS ) assert config.get("EXCLUDED_MULTI_PARTS_FILES") == sorted(DEFAULT_EXCLUDED_FILES) + assert config.get("DEFAULT_EXCLUDED_MEDIA_DIRS") == list( + DEFAULT_EXCLUDED_MEDIA_DIRS + ) assert config.get("PLATFORMS_BINDING") == {} assert not config.get("SKIP_HASH_CALCULATION") assert config.get("GAMELIST_MEDIA_THUMBNAIL") == "box2d" diff --git a/frontend/src/__generated__/models/ConfigResponse.ts b/frontend/src/__generated__/models/ConfigResponse.ts index 53c74d633..417d297f7 100644 --- a/frontend/src/__generated__/models/ConfigResponse.ts +++ b/frontend/src/__generated__/models/ConfigResponse.ts @@ -16,6 +16,7 @@ export type ConfigResponse = { EXCLUDED_MULTI_PARTS_EXT: Array; EXCLUDED_MULTI_PARTS_FILES: Array; DEFAULT_EXCLUDED_DIRS: Array; + DEFAULT_EXCLUDED_MEDIA_DIRS: Array; DEFAULT_EXCLUDED_FILES: Array; DEFAULT_EXCLUDED_EXTENSIONS: Array; PLATFORMS_BINDING: Record; diff --git a/frontend/src/stores/config.ts b/frontend/src/stores/config.ts index db4a09821..f96c4d8f3 100644 --- a/frontend/src/stores/config.ts +++ b/frontend/src/stores/config.ts @@ -22,6 +22,7 @@ const defaultConfig = { EXCLUDED_MULTI_PARTS_EXT: [], EXCLUDED_MULTI_PARTS_FILES: [], DEFAULT_EXCLUDED_DIRS: [], + DEFAULT_EXCLUDED_MEDIA_DIRS: [], DEFAULT_EXCLUDED_FILES: [], DEFAULT_EXCLUDED_EXTENSIONS: [], PLATFORMS_BINDING: {}, diff --git a/frontend/src/v2/components/Settings/ExcludedSection.vue b/frontend/src/v2/components/Settings/ExcludedSection.vue index 38c2d7482..02eb7bbbd 100644 --- a/frontend/src/v2/components/Settings/ExcludedSection.vue +++ b/frontend/src/v2/components/Settings/ExcludedSection.vue @@ -97,23 +97,28 @@ const exclusionDefs = computed(() => [ }, ]); -const DEFAULT_LIST_MAP: Record< - ExclusionDef["key"], +type DefaultListKey = | "DEFAULT_EXCLUDED_DIRS" + | "DEFAULT_EXCLUDED_MEDIA_DIRS" | "DEFAULT_EXCLUDED_FILES" - | "DEFAULT_EXCLUDED_EXTENSIONS" -> = { - EXCLUDED_PLATFORMS: "DEFAULT_EXCLUDED_DIRS", - EXCLUDED_SINGLE_FILES: "DEFAULT_EXCLUDED_FILES", - EXCLUDED_SINGLE_EXT: "DEFAULT_EXCLUDED_EXTENSIONS", - EXCLUDED_MULTI_FILES: "DEFAULT_EXCLUDED_DIRS", - EXCLUDED_MULTI_PARTS_FILES: "DEFAULT_EXCLUDED_FILES", - EXCLUDED_MULTI_PARTS_EXT: "DEFAULT_EXCLUDED_EXTENSIONS", + | "DEFAULT_EXCLUDED_EXTENSIONS"; + +const DEFAULT_LIST_MAP: Record = { + EXCLUDED_PLATFORMS: ["DEFAULT_EXCLUDED_DIRS"], + EXCLUDED_SINGLE_FILES: ["DEFAULT_EXCLUDED_FILES"], + EXCLUDED_SINGLE_EXT: ["DEFAULT_EXCLUDED_EXTENSIONS"], + EXCLUDED_MULTI_FILES: [ + "DEFAULT_EXCLUDED_DIRS", + "DEFAULT_EXCLUDED_MEDIA_DIRS", + ], + EXCLUDED_MULTI_PARTS_FILES: ["DEFAULT_EXCLUDED_FILES"], + EXCLUDED_MULTI_PARTS_EXT: ["DEFAULT_EXCLUDED_EXTENSIONS"], }; function isDefault(key: ExclusionDef["key"], value: string): boolean { - const defaults = config.value[DEFAULT_LIST_MAP[key]] || []; - return defaults.includes(value); + return DEFAULT_LIST_MAP[key].some((list) => + (config.value[list] || []).includes(value), + ); } type Row = {