From 09b3c926903d8043f3ba606084f508d7f0b132aa Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Mon, 17 Aug 2026 16:51:41 -0500 Subject: [PATCH 1/6] fix(docker): ship valkey-cli and log watchdog restarts The image bundles valkey but not its CLI, which Alpine packages separately, so the internal cache cannot be inspected from inside a running container. The watchdog also restarted dead processes silently, hiding both the crash and whatever state died with it. Co-Authored-By: Claude Opus 5 --- docker/Dockerfile | 6 +++++- docker/init_scripts/init | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0c4901c86..3cd3fc5c4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -165,6 +165,9 @@ RUN git clone https://github.com/evanmiller/mod_zip.git && \ FROM nginx:${NGINX_VERSION}-alpine${ALPINE_VERSION}@sha256:${NGINX_SHA256} AS production-stage ARG WEBSERVER_FOLDER=/var/www/html +# valkey-cli is packaged separately from valkey on Alpine, and nothing in the +# image invokes it. It ships so operators can inspect the internal cache, which +# holds metadata that only a task re-run can rebuild. RUN apk add --no-cache \ bash \ libarchive-tools \ @@ -174,7 +177,8 @@ RUN apk add --no-cache \ nodejs \ 7zip \ tzdata \ - valkey + valkey \ + valkey-cli # Add Python by copying it from the official Docker image. This way, we don't rely on Alpine's # Python version, which could not be the same as the one used in the backend build stage. diff --git a/docker/init_scripts/init b/docker/init_scripts/init index a1f4bb4a3..f9f4b7d6f 100755 --- a/docker/init_scripts/init +++ b/docker/init_scripts/init @@ -300,6 +300,10 @@ watchdog_process_pid() { # Check if the pid we last wrote to our state file is actually active PID=$(cat "/tmp/${PROCESS}.pid") || true if [[ ! -d "/proc/${PID}" ]]; then + # Restarting silently hides both the crash and whatever died with it. + # A valkey restart in particular drops every cached key written since + # the last snapshot, which no amount of retrying brings back. + warn_log "${PROCESS} exited unexpectedly, restarting it" start_bin_"${PROCESS}" fi else From 6ce0a2f52885a18539b9095145682dca9525cc79 Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Mon, 17 Aug 2026 16:51:42 -0500 Subject: [PATCH 2/6] fix(launchbox): match titles differing only by punctuation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LaunchBox titles carry colons, diacritics and characters a filesystem forbids that a ROM filename cannot, so an exact-key lookup misses games the dump holds: "Burnout Revenge" against "Burnout: Revenge", "Asterix" against "Astérix", "AC-DC" against "AC/DC". Index every title under a folded form as well, and consult it only once every exact form has missed so an exact hit still wins. Measured over the 2585 Redump-style PlayStation 2 titles the dump names, this lifts matching from 89.8% to 96.7%. All five colliding folded keys are LaunchBox's own duplicate records for a single game. Co-Authored-By: Claude Opus 5 --- .../launchbox_handler/remote_source.py | 17 +++++- .../metadata/launchbox_handler/types.py | 3 + .../metadata/launchbox_handler/utils.py | 18 ++++++ .../scheduled/update_launchbox_metadata.py | 11 ++++ .../metadata/test_launchbox_handler.py | 59 +++++++++++++++++++ .../tasks/test_update_launchbox_metadata.py | 13 +++- 6 files changed, 118 insertions(+), 3 deletions(-) diff --git a/backend/handler/metadata/launchbox_handler/remote_source.py b/backend/handler/metadata/launchbox_handler/remote_source.py index 4670b2d0f..7ee9f58ae 100644 --- a/backend/handler/metadata/launchbox_handler/remote_source.py +++ b/backend/handler/metadata/launchbox_handler/remote_source.py @@ -9,10 +9,11 @@ from .types import ( LAUNCHBOX_MAME_KEY, LAUNCHBOX_METADATA_ALTERNATE_NAME_KEY, LAUNCHBOX_METADATA_DATABASE_ID_KEY, + LAUNCHBOX_METADATA_FOLDED_NAME_KEY, LAUNCHBOX_METADATA_IMAGE_KEY, LAUNCHBOX_METADATA_NAME_KEY, ) -from .utils import deinvert_article, file_name_forms +from .utils import deinvert_article, file_name_forms, fold_title class RemoteSource: @@ -89,6 +90,20 @@ class RemoteSource: if entry.get("Platform") == platform_name: return entry + # Last resort: compare titles with punctuation, accents and spacing + # removed. A dump filename can only differ from the title it was cut + # from by characters `fold_title` drops, so this is checked after every + # exact form has missed. + for candidate in candidates: + folded = fold_title(candidate) + if not folded: + continue + folded_index_entry = await async_cache.hget( + LAUNCHBOX_METADATA_FOLDED_NAME_KEY, f"{folded}:{platform_name}" + ) + if folded_index_entry: + return json.loads(folded_index_entry) + return None async def get_rom_by_file_name( diff --git a/backend/handler/metadata/launchbox_handler/types.py b/backend/handler/metadata/launchbox_handler/types.py index a71c2a8ad..9eac445e5 100644 --- a/backend/handler/metadata/launchbox_handler/types.py +++ b/backend/handler/metadata/launchbox_handler/types.py @@ -13,6 +13,9 @@ LAUNCHBOX_METADATA_NAME_KEY: Final[str] = "romm:launchbox_metadata_name" LAUNCHBOX_METADATA_ALTERNATE_NAME_KEY: Final[str] = ( "romm:launchbox_metadata_alternate_name" ) +# Titles reduced to letters and digits, so a filename only differing from the +# dump by punctuation still resolves. See `fold_title` for what it drops. +LAUNCHBOX_METADATA_FOLDED_NAME_KEY: Final[str] = "romm:launchbox_metadata_folded_name" LAUNCHBOX_METADATA_IMAGE_KEY: Final[str] = "romm:launchbox_metadata_image" LAUNCHBOX_MAME_KEY: Final[str] = "romm:launchbox_mame" LAUNCHBOX_FILES_KEY: Final[str] = "romm:launchbox_files" diff --git a/backend/handler/metadata/launchbox_handler/utils.py b/backend/handler/metadata/launchbox_handler/utils.py index 1543b4db7..cce53c4a4 100644 --- a/backend/handler/metadata/launchbox_handler/utils.py +++ b/backend/handler/metadata/launchbox_handler/utils.py @@ -1,4 +1,5 @@ import re +import unicodedata from datetime import datetime from pathlib import Path @@ -41,6 +42,23 @@ def deinvert_article(term: str) -> str | None: return f"{match.group('article')} {match.group('title')}{subtitle}" +def fold_title(title: str) -> str: + """Reduce a title to letters and digits for punctuation-blind comparison. + + Dump titles and ROM filenames disagree on punctuation constantly: LaunchBox + writes a colon a filename has no room for ("Burnout: Revenge"), keeps + diacritics a dump filename drops ("Astérix"), and uses characters a + filesystem forbids ("AC/DC"). Folding both sides to `burnoutrevenge` / + `asterix` / `acdc` makes those the same key. + + Spaces go too, so "Area-51" and "Area 51" agree. Returns "" for a title + with nothing left to compare, which callers must treat as no key. + """ + decomposed = unicodedata.normalize("NFKD", title.casefold()) + without_accents = "".join(c for c in decomposed if not unicodedata.combining(c)) + return re.sub(r"[^a-z0-9]+", "", without_accents) + + def file_name_forms(file_name: str) -> list[str]: """Lowercased extension-less forms of a file name, most specific first. diff --git a/backend/tasks/scheduled/update_launchbox_metadata.py b/backend/tasks/scheduled/update_launchbox_metadata.py index aed54081f..98b0a3877 100644 --- a/backend/tasks/scheduled/update_launchbox_metadata.py +++ b/backend/tasks/scheduled/update_launchbox_metadata.py @@ -19,11 +19,13 @@ from handler.metadata.launchbox_handler.types import ( LAUNCHBOX_MAME_KEY, LAUNCHBOX_METADATA_ALTERNATE_NAME_KEY, LAUNCHBOX_METADATA_DATABASE_ID_KEY, + LAUNCHBOX_METADATA_FOLDED_NAME_KEY, LAUNCHBOX_METADATA_IMAGE_KEY, LAUNCHBOX_METADATA_INITIAL_IMPORT_KEY, LAUNCHBOX_METADATA_NAME_KEY, LAUNCHBOX_PLATFORMS_KEY, ) +from handler.metadata.launchbox_handler.utils import fold_title from handler.redis_handler import async_cache from logger.logger import log from tasks.tasks import RemoteFilePullTask, TaskType @@ -199,6 +201,15 @@ class UpdateLaunchboxMetadataTask(RemoteFilePullTask): _element_to_dict(elem), ) + folded = fold_title(name_elem.text) + if folded: + await writer.hset( + LAUNCHBOX_METADATA_FOLDED_NAME_KEY, + f"{folded}" + f":{platform_elem.text.strip()}", + _element_to_dict(elem), + ) + elif elem.tag == "GameAlternateName": alternate_name_elem = elem.find("AlternateName") if ( diff --git a/backend/tests/handler/metadata/test_launchbox_handler.py b/backend/tests/handler/metadata/test_launchbox_handler.py index 1485bf3d0..181e3cc79 100644 --- a/backend/tests/handler/metadata/test_launchbox_handler.py +++ b/backend/tests/handler/metadata/test_launchbox_handler.py @@ -36,6 +36,7 @@ from handler.metadata.launchbox_handler.types import ( LAUNCHBOX_MAME_KEY, LAUNCHBOX_METADATA_ALTERNATE_NAME_KEY, LAUNCHBOX_METADATA_DATABASE_ID_KEY, + LAUNCHBOX_METADATA_FOLDED_NAME_KEY, LAUNCHBOX_METADATA_IMAGE_KEY, LAUNCHBOX_METADATA_INITIAL_IMPORT_KEY, LAUNCHBOX_METADATA_NAME_KEY, @@ -46,6 +47,7 @@ from handler.metadata.launchbox_handler.types import ( from handler.metadata.launchbox_handler.utils import ( coalesce, deinvert_article, + fold_title, launchbox_region_to_shortcode, parse_playmode, parse_release_date, @@ -667,6 +669,63 @@ class TestRemoteSourceGetRom: # The literal name is still tried first. assert queried[0] == "legend of zelda, the: ocarina of time:Nintendo 64" + @pytest.mark.parametrize( + ("search_term", "dump_title"), + [ + # LaunchBox adds a colon the filename has no room for. + ("burnout revenge", "Burnout: Revenge"), + # The dump keeps diacritics a No-Intro filename drops. + ("asterix at the olympic games", "Astérix at the Olympic Games"), + # "/" cannot appear in a filename at all. + ("ac-dc live: rock band track pack", "AC/DC Live: Rock Band Track Pack"), + # Hyphen against space. + ("area 51", "Area-51"), + ], + ) + async def test_folded_title_match( + self, source: RemoteSource, search_term: str, dump_title: str + ): + """Punctuation-only differences resolve through the folded index.""" + entry = {"DatabaseID": "77", "Name": dump_title} + folded_field = f"{fold_title(dump_title)}:Sony Playstation 2" + + async def side_effect(key, field): + if key == LAUNCHBOX_METADATA_FOLDED_NAME_KEY and field == folded_field: + return json.dumps(entry) + return None + + with patch.object( + async_cache, "hget", new_callable=AsyncMock, side_effect=side_effect + ): + result = await source.get_rom(search_term, "ps2", assume_cache_present=True) + + assert result is not None + assert result.get("DatabaseID", None) == "77" + + async def test_folded_match_is_only_tried_after_exact_forms( + self, source: RemoteSource + ): + """Folding discards information, so an exact hit must always win.""" + exact = {"DatabaseID": "1", "Name": "Burnout Revenge"} + folded = {"DatabaseID": "2", "Name": "Burnout: Revenge"} + + async def side_effect(key, _field): + if key == LAUNCHBOX_METADATA_NAME_KEY: + return json.dumps(exact) + if key == LAUNCHBOX_METADATA_FOLDED_NAME_KEY: + return json.dumps(folded) + return None + + with patch.object( + async_cache, "hget", new_callable=AsyncMock, side_effect=side_effect + ): + result = await source.get_rom( + "burnout revenge", "ps2", assume_cache_present=True + ) + + assert result is not None + assert result.get("DatabaseID", None) == "1" + async def test_no_match_returns_none(self, source: RemoteSource): with patch.object( async_cache, "hget", new_callable=AsyncMock, return_value=None diff --git a/backend/tests/tasks/test_update_launchbox_metadata.py b/backend/tests/tasks/test_update_launchbox_metadata.py index a19b8b750..1d3d177e5 100644 --- a/backend/tests/tasks/test_update_launchbox_metadata.py +++ b/backend/tests/tasks/test_update_launchbox_metadata.py @@ -11,6 +11,7 @@ from handler.metadata.launchbox_handler.types import ( LAUNCHBOX_MAME_KEY, LAUNCHBOX_METADATA_ALTERNATE_NAME_KEY, LAUNCHBOX_METADATA_DATABASE_ID_KEY, + LAUNCHBOX_METADATA_FOLDED_NAME_KEY, LAUNCHBOX_METADATA_IMAGE_KEY, LAUNCHBOX_METADATA_INITIAL_IMPORT_KEY, LAUNCHBOX_METADATA_NAME_KEY, @@ -151,7 +152,7 @@ class TestUpdateLaunchboxMetadataTask: # Check hset call details hset_calls = mock_pipe.hset.call_args_list - assert len(hset_calls) == 12 + assert len(hset_calls) == 14 platform_calls = [ call for call in hset_calls if call[0][0] == LAUNCHBOX_PLATFORMS_KEY @@ -174,11 +175,18 @@ class TestUpdateLaunchboxMetadataTask: metadata_image_calls = [ call for call in hset_calls if call[0][0] == LAUNCHBOX_METADATA_IMAGE_KEY ] + metadata_folded_calls = [ + call + for call in hset_calls + if call[0][0] == LAUNCHBOX_METADATA_FOLDED_NAME_KEY + ] assert len(metadata_id_calls) == 2 assert len(metadata_name_calls) == 2 assert len(metadata_alt_calls) == 1 assert len(metadata_image_calls) == 1 + # Every named game is indexed under its folded title too. + assert len(metadata_folded_calls) == len(metadata_name_calls) mame_calls = [call for call in hset_calls if call[0][0] == LAUNCHBOX_MAME_KEY] assert len(mame_calls) == 2 @@ -324,7 +332,7 @@ class TestUpdateLaunchboxMetadataTaskIntegration: # Check hset call details hset_calls = mock_pipe.hset.call_args_list - assert len(hset_calls) == 12 + assert len(hset_calls) == 14 # Verify that all expected Redis keys were used redis_keys_used = [call[0][0] for call in hset_calls] @@ -333,6 +341,7 @@ class TestUpdateLaunchboxMetadataTaskIntegration: LAUNCHBOX_PLATFORMS_KEY, LAUNCHBOX_METADATA_DATABASE_ID_KEY, LAUNCHBOX_METADATA_NAME_KEY, + LAUNCHBOX_METADATA_FOLDED_NAME_KEY, LAUNCHBOX_METADATA_ALTERNATE_NAME_KEY, LAUNCHBOX_METADATA_IMAGE_KEY, LAUNCHBOX_MAME_KEY, From 51d27c2ec2f863052bc4ebfc378fc1550856b447 Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Mon, 17 Aug 2026 16:51:44 -0500 Subject: [PATCH 3/6] feat(scan): record which LaunchBox sources a scan can read A local install is consulted on every lookup and the per-scan switch only decides whether the cloud store is read too, so either can be selected while holding nothing. A lookup against an absent source is silent, which left "no install mounted" indistinguishable from "no matches" across a whole platform. Co-Authored-By: Claude Opus 5 --- backend/endpoints/sockets/scan.py | 41 ++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/backend/endpoints/sockets/scan.py b/backend/endpoints/sockets/scan.py index 80602db61..41d5534af 100644 --- a/backend/endpoints/sockets/scan.py +++ b/backend/endpoints/sockets/scan.py @@ -39,7 +39,12 @@ from handler.filesystem import ( fs_rom_handler, ) from handler.filesystem.roms_handler import FSRom -from handler.metadata import meta_gamelist_handler, meta_hltb_handler +from handler.metadata import ( + meta_gamelist_handler, + meta_hltb_handler, + meta_launchbox_handler, +) +from handler.metadata.launchbox_handler.types import LAUNCHBOX_PLATFORMS_DIR from handler.metadata.ss_handler import add_ss_auth_to_url from handler.metadata.ss_handler import begin_scan as begin_ss_scan from handler.metadata.ss_handler import get_preferred_media_types @@ -1068,6 +1073,40 @@ async def scan_platforms( if MetadataSource.HLTB in metadata_sources: await meta_hltb_handler.initialize() + # A local install is read on every lookup; the per-scan switch only decides + # whether the cloud store is consulted as well. Both can be empty, and a + # lookup against an absent source is silent, so what LaunchBox can actually + # read is recorded here rather than left to be inferred from a platform's + # worth of empty results. + if MetadataSource.LAUNCHBOX in metadata_sources: + local_available = meta_launchbox_handler.is_local_enabled() + store_available = launchbox_remote_enabled and ( + await meta_launchbox_handler.is_remote_store_populated() + ) + readable = [ + name + for name, present in ( + (f"a {hl('local')} install", local_available), + (f"the {hl('cloud')} store", store_available), + ) + if present + ] + if readable: + log.info(f"LaunchBox is reading {' and '.join(readable)}") + elif launchbox_remote_enabled: + log.warning( + f"{hl(emoji.EMOJI_WARNING, color=LIGHTYELLOW)} LaunchBox has nothing " + f"to read: no install at {hl(str(LAUNCHBOX_PLATFORMS_DIR))} and the " + "cloud store is empty. Run the LaunchBox metadata update task." + ) + else: + log.warning( + f"{hl(emoji.EMOJI_WARNING, color=LIGHTYELLOW)} LaunchBox is set to " + f"local only and no install was found at " + f"{hl(str(LAUNCHBOX_PLATFORMS_DIR))}, so it will match nothing. " + "Switch it to cloud, or mount an install there." + ) + # Resolve the platforms that will actually be scanned. When no platform ids # are provided, every filesystem platform is scanned. db_platforms = db_platform_handler.get_platforms() From 49291510482dbb5a957e408922ad27dee1b8118a Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Mon, 17 Aug 2026 17:05:31 -0500 Subject: [PATCH 4/6] fix(launchbox): keep letters of every script when folding a title MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Folding to ASCII alone reduced a title written in another script to whatever digits it carried, so "三國立志傳2" and "忍者村大战2" shared one key and four Windows titles collapsed onto "2". Keeping every alphanumeric character instead separates them and gives the 208 titles that folded to nothing a key of their own. Measured over all 187067 named games in the dump, colliding folded keys drop from 597 to 551 and the PlayStation 2 gain is unchanged at 96.7%. Every surviving collision is a punctuation variant of one game, and none differ in their digits, so no entry in a series folds onto another. Co-Authored-By: Claude Opus 5 --- .../metadata/launchbox_handler/utils.py | 6 +++++- .../metadata/test_launchbox_handler.py | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/backend/handler/metadata/launchbox_handler/utils.py b/backend/handler/metadata/launchbox_handler/utils.py index cce53c4a4..cc64d4ca6 100644 --- a/backend/handler/metadata/launchbox_handler/utils.py +++ b/backend/handler/metadata/launchbox_handler/utils.py @@ -53,10 +53,14 @@ def fold_title(title: str) -> str: Spaces go too, so "Area-51" and "Area 51" agree. Returns "" for a title with nothing left to compare, which callers must treat as no key. + + Letters of every script survive. Keeping only ASCII would reduce a title + written in one to whatever digits it carries, collapsing "三國立志傳2" and + "忍者村大战2" onto the same key. """ decomposed = unicodedata.normalize("NFKD", title.casefold()) without_accents = "".join(c for c in decomposed if not unicodedata.combining(c)) - return re.sub(r"[^a-z0-9]+", "", without_accents) + return "".join(c for c in without_accents if c.isalnum()) def file_name_forms(file_name: str) -> list[str]: diff --git a/backend/tests/handler/metadata/test_launchbox_handler.py b/backend/tests/handler/metadata/test_launchbox_handler.py index 181e3cc79..3f94e5f62 100644 --- a/backend/tests/handler/metadata/test_launchbox_handler.py +++ b/backend/tests/handler/metadata/test_launchbox_handler.py @@ -702,6 +702,27 @@ class TestRemoteSourceGetRom: assert result is not None assert result.get("DatabaseID", None) == "77" + @pytest.mark.parametrize( + ("title", "expected"), + [ + ("Burnout: Revenge", "burnoutrevenge"), + ("Astérix at the Olympic Games", "asterixattheolympicgames"), + ("AC/DC Live", "acdclive"), + ("Area-51", "area51"), + # A title in a non-Latin script keeps its letters. Reducing it to + # its digits would collide with every other title numbered alike. + ("三國立志傳2", "三國立志傳2"), + ("Зона 51", "зона51"), + # Nothing comparable left, so callers must treat it as no key. + (":: -- ::", ""), + ], + ) + def test_fold_title(self, title: str, expected: str): + assert fold_title(title) == expected + + def test_fold_title_separates_titles_sharing_only_their_digits(self): + assert fold_title("三國立志傳2") != fold_title("忍者村大战2") + async def test_folded_match_is_only_tried_after_exact_forms( self, source: RemoteSource ): From e1fe2caf0f7c018ff1eac80d7caea49b46fd1edf Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Mon, 17 Aug 2026 17:19:57 -0500 Subject: [PATCH 5/6] fix(launchbox): keep marks the script spells with when folding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A mark was dropped whenever it was not alphanumeric, and the accent strip before it removed every mark carrying a combining class. Between them they took the vowel signs and viramas Indic and Thai scripts spell with, so "हिन्दी गेम" folded to "हनदगम" and titles differing only in those marks collided. A mark now only goes when it sits on a Latin letter, which is the case it was meant for. Collisions across the dump are unchanged at 551 of 186505 keys, none differing in their digits, and the PlayStation 2 gain still measures 96.7%. Also build each game's dict once rather than per index write. Co-Authored-By: Claude Opus 5 --- .../metadata/launchbox_handler/utils.py | 18 +++++++++++++++--- .../scheduled/update_launchbox_metadata.py | 12 +++++++----- .../handler/metadata/test_launchbox_handler.py | 4 ++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/backend/handler/metadata/launchbox_handler/utils.py b/backend/handler/metadata/launchbox_handler/utils.py index cc64d4ca6..33c8a6444 100644 --- a/backend/handler/metadata/launchbox_handler/utils.py +++ b/backend/handler/metadata/launchbox_handler/utils.py @@ -57,10 +57,22 @@ def fold_title(title: str) -> str: Letters of every script survive. Keeping only ASCII would reduce a title written in one to whatever digits it carries, collapsing "三國立志傳2" and "忍者村大战2" onto the same key. + + A mark only goes when it sits on a Latin letter, where it is an accent the + two sides may disagree about ("Astérix" against "Asterix"). Elsewhere it + spells the word: Devanagari and Thai build syllables from marks, so dropping + them would reduce "हिन्दी" to "हनद" and collide titles that differ. """ - decomposed = unicodedata.normalize("NFKD", title.casefold()) - without_accents = "".join(c for c in decomposed if not unicodedata.combining(c)) - return "".join(c for c in without_accents if c.isalnum()) + kept: list[str] = [] + for char in unicodedata.normalize("NFKD", title.casefold()): + if unicodedata.category(char).startswith("M"): + if kept and "a" <= kept[-1] <= "z": + continue + kept.append(char) + elif char.isalnum(): + kept.append(char) + + return "".join(kept) def file_name_forms(file_name: str) -> list[str]: diff --git a/backend/tasks/scheduled/update_launchbox_metadata.py b/backend/tasks/scheduled/update_launchbox_metadata.py index 98b0a3877..cbf957fb9 100644 --- a/backend/tasks/scheduled/update_launchbox_metadata.py +++ b/backend/tasks/scheduled/update_launchbox_metadata.py @@ -193,21 +193,23 @@ class UpdateLaunchboxMetadataTask(RemoteFilePullTask): and platform_elem is not None and platform_elem.text ): + platform_name = platform_elem.text.strip() + game = _element_to_dict(elem) + # Use a unique combination of name and platform as the key await writer.hset( LAUNCHBOX_METADATA_NAME_KEY, f"{name_elem.text.strip().lower()}" - f":{platform_elem.text.strip()}", - _element_to_dict(elem), + f":{platform_name}", + game, ) folded = fold_title(name_elem.text) if folded: await writer.hset( LAUNCHBOX_METADATA_FOLDED_NAME_KEY, - f"{folded}" - f":{platform_elem.text.strip()}", - _element_to_dict(elem), + f"{folded}:{platform_name}", + game, ) elif elem.tag == "GameAlternateName": diff --git a/backend/tests/handler/metadata/test_launchbox_handler.py b/backend/tests/handler/metadata/test_launchbox_handler.py index 3f94e5f62..b9d1f6057 100644 --- a/backend/tests/handler/metadata/test_launchbox_handler.py +++ b/backend/tests/handler/metadata/test_launchbox_handler.py @@ -713,6 +713,10 @@ class TestRemoteSourceGetRom: # its digits would collide with every other title numbered alike. ("三國立志傳2", "三國立志傳2"), ("Зона 51", "зона51"), + # Scripts that build syllables from marks keep them; stripping to + # alphanumerics alone would spell these titles differently. + ("हिन्दी गेम", "हिन्दीगेम"), + ("สนุกเกอร์", "สนุกเกอร์"), # Nothing comparable left, so callers must treat it as no key. (":: -- ::", ""), ], From 9e92e325f7cea3fcd0194745d3351ef5d933e9dd Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Tue, 18 Aug 2026 08:11:09 -0500 Subject: [PATCH 6/6] chore: drop review-flagged comments Co-Authored-By: Claude Opus 5 --- backend/handler/metadata/launchbox_handler/types.py | 2 -- docker/Dockerfile | 3 --- docker/init_scripts/init | 3 --- 3 files changed, 8 deletions(-) diff --git a/backend/handler/metadata/launchbox_handler/types.py b/backend/handler/metadata/launchbox_handler/types.py index 9eac445e5..5d86db428 100644 --- a/backend/handler/metadata/launchbox_handler/types.py +++ b/backend/handler/metadata/launchbox_handler/types.py @@ -13,8 +13,6 @@ LAUNCHBOX_METADATA_NAME_KEY: Final[str] = "romm:launchbox_metadata_name" LAUNCHBOX_METADATA_ALTERNATE_NAME_KEY: Final[str] = ( "romm:launchbox_metadata_alternate_name" ) -# Titles reduced to letters and digits, so a filename only differing from the -# dump by punctuation still resolves. See `fold_title` for what it drops. LAUNCHBOX_METADATA_FOLDED_NAME_KEY: Final[str] = "romm:launchbox_metadata_folded_name" LAUNCHBOX_METADATA_IMAGE_KEY: Final[str] = "romm:launchbox_metadata_image" LAUNCHBOX_MAME_KEY: Final[str] = "romm:launchbox_mame" diff --git a/docker/Dockerfile b/docker/Dockerfile index 3cd3fc5c4..07dc03e46 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -165,9 +165,6 @@ RUN git clone https://github.com/evanmiller/mod_zip.git && \ FROM nginx:${NGINX_VERSION}-alpine${ALPINE_VERSION}@sha256:${NGINX_SHA256} AS production-stage ARG WEBSERVER_FOLDER=/var/www/html -# valkey-cli is packaged separately from valkey on Alpine, and nothing in the -# image invokes it. It ships so operators can inspect the internal cache, which -# holds metadata that only a task re-run can rebuild. RUN apk add --no-cache \ bash \ libarchive-tools \ diff --git a/docker/init_scripts/init b/docker/init_scripts/init index f9f4b7d6f..bc888149a 100755 --- a/docker/init_scripts/init +++ b/docker/init_scripts/init @@ -300,9 +300,6 @@ watchdog_process_pid() { # Check if the pid we last wrote to our state file is actually active PID=$(cat "/tmp/${PROCESS}.pid") || true if [[ ! -d "/proc/${PID}" ]]; then - # Restarting silently hides both the crash and whatever died with it. - # A valkey restart in particular drops every cached key written since - # the last snapshot, which no amount of retrying brings back. warn_log "${PROCESS} exited unexpectedly, restarting it" start_bin_"${PROCESS}" fi