mirror of
https://github.com/rommapp/romm.git
synced 2026-12-04 12:52:19 +01:00
31eb7dbdb27cec19104eb3665b23cbd1c2cce235
788 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
257025ccd7 |
fix(downloads): keep converted copies' ETag stable so downloads resume (#5442)
Serving a cached conversion touched the copy's mtime to record demand for TTL cleanup, and nginx builds its default ETag from mtime and size, so the ETag changed on every request and Range/If-Range resumes always got a full 200. Record serves on a `.served` marker in the key dir instead; cleanup already takes the newest mtime among the dir's files, so it reads the marker and falls back to the copy's own mtime, and removes the marker with the dir. Fixes #5239 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
183ee3b89f |
feat(platforms): enrich discovery cards and preserve AVIF animations (#5433)
Fetch original launch years and current platform logos during scans, retain curated platform icons, and show launch year and type on responsive discovery cards. Preserve animated AVIF frames during thumbnail and WebP conversion. Closes rommapp/romm#5432 Authored with Codex assistance, including implementation and tests. |
||
|
|
4393b70973 |
feat(media): JPEG XL library images and cover uploads (#5438)
* feat(media): serve JPEG XL library images inline Add .jxl to the image extensions the download endpoint serves inline, with an explicit image/jxl type since mimetypes doesn't know it, and to the frontend lists that pick artwork and folder screenshots out of rom.files. AVIF was already covered; the new test pins both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs * feat(media): accept JPEG XL cover uploads through a Pillow plugin Pillow 13 reads AVIF but not JPEG XL. pillow-jxl-plugin registers a JXL codec with Pillow (imported once in utils/images, which the cover and WebP-conversion code already load). It ships musllinux wheels for the image's amd64 and arm64 builds. ROM and collection artwork uploads now accept image/jxl and store it re-encoded as PNG, since covers are served in their stored format and not every browser renders JPEG XL. Avatars, stored as uploaded, keep the PNG/JPEG/WebP/GIF allowlist. The plugin is GPL-3.0, which is compatible with RomM's AGPL-3.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs * test(roms): expect JPEG XL in the artwork rejection message Artwork uploads now also accept JPEG XL, so the rejection message lists it. The collection tests were updated with the change; this ROM one was missed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs * fix(media): list library JPEG XL images only where the browser renders them Library files are served as stored, and Chrome and Firefox render no JPEG XL, so .jxl artwork and folder screenshots showed as broken tiles there. A one-time probe decodes a 22-byte JPEG XL image and the artwork and screenshot lists only include .jxl files once it succeeds (Safari), updating reactively when the answer arrives. Chromium 153 fails the probe, so the files stay hidden there as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs * fix(media): size-check JPEG XL before decoding and keep it out of screenshot uploads pillow-jxl decodes every pixel in _open(), before Pillow's decompression-bomb check sees the size, so a small, highly compressed JXL declaring a huge canvas could exhaust memory. utils/jxl reads the width and height from the codestream SizeHeader (bare or inside a container) and runs Pillow's own bomb check on them first, then registers this guarded decoder in place of the plugin's. The decoder raises RuntimeError on a corrupt file, which escaped store_artwork as a 500. The guard turns it into SyntaxError, so Pillow reports UnidentifiedImageError and the upload takes the same path as a corrupt PNG. POST /api/screenshots validated against the library inline list, so it started accepting .jxl, but the asset endpoint serves those as attachments. Screenshot uploads now use their own list without JPEG XL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs * style(media): one-sentence jxl docstring and a narrowed mock call in the JXL test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs * style(media): one-sentence canRenderJxl doc comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1642a323c0 | fix(sort): strip only configured articles, and keep custom sort keys as typed (#5429) | ||
|
|
0f75e6aaf4 |
fix(client-tokens): let a client token revoke itself without me.write (#5419)
* fix(client-tokens): let a client token revoke itself without me.write
A device that signs out or re-pairs had no way to revoke its own token
unless it held me.write, which also lets it mint tokens and approve
pairings. DELETE /api/client-tokens/{id} now skips the me.write check
when the id is the token authenticating the request.
Fixes #5274
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(client-tokens): code-review pass on self-revoke
Annotate raise_auth_error as NoReturn, trim the delete_token docstring, and
cover a me.write token revoking a sibling, the revoked token failing to
authenticate, and socket closure on self-revoke.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(client-tokens): revoke the calling token through DELETE /current
Self-revoke moves to an id-less route so a device never needs to know its
token id, and DELETE /{token_id} keeps me.write in its decorator and in
OpenAPI. The device-authorization token response now also returns token_id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(client-tokens): simplify pass, reuse raise_auth_error for /current
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* revert(client-tokens): drop DELETE /current and the device-flow token_id
Self-revoke stays on DELETE /{token_id} with the in-handler check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(device-auth): return the issued token's id from the device token poll
A device paired through the device-authorization flow can now revoke its
own token with DELETE /api/client-tokens/{id}, as tokens from /exchange can.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Update docs/BACKEND_ARCHITECTURE.md
* docs: format client tokens table
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
d15cd9e7a1 |
fix: keep summary line breaks and strip provider HTML (#5413)
* fix(ui): keep line breaks in the game summary Normalize CRLF and bare CR to LF and render the summary with white-space: pre-line so multi-line summaries keep their structure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(metadata): turn HTML in provider summaries into plain text Add utils.html_text.html_to_text, a parser-based helper that drops known HTML tags, maps paragraphs, line breaks and list items to newlines, and unescapes entities. Unknown tags such as "<Start>" stay as literal text. Moby, ScreenScraper, Steam, Flashpoint and LaunchBox summaries go through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(metadata): separate table cells and keep bullets on their text Addresses Greptile review on #5413: adjacent td/th cells now get a space between them, and a list item wrapping its text in a paragraph keeps the bullet on the same line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
638601f480 |
fix(webp): raise the cover WebP quality to 95 (#5410)
* fix(webp): raise the cover WebP quality to 95 Quality 90 left visible artifacts on box art with small text. On a sample of real covers, 95 adds about 3 dB of luma PSNR for about 25% more bytes (small covers go from 20% to 25% of the PNG size, big ones from 27% to 36%); 100 costs another third for little gain. Small animated covers now use the same quality instead of Pillow's default of 80, and the ignored optimize flag is dropped from the static WebP save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Apply suggestion from @greptile-apps[bot] Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> |
||
|
|
81b617459b |
fix(db): bump client token and device last-used timestamps without a prior read (#5384)
* fix(db): bump client token and device last-used timestamps without a prior read update_last_used() and update_last_seen_debounced() read the row with session.get() and then updated it in the same transaction. When two requests with the same Client API Token ran concurrently and both passed the debounce check, the second UPDATE hit MariaDB error 1020 (Record has changed since last read), so a read-only GET returned HTTP 500. Make each a single conditional UPDATE that only touches the row when the debounce window has passed. Fixes #5379 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(db): code-review fixes for last-used race tests Reuse the executed_statements fixture, scope race listeners to sync_engine, add the device race test, drop an unused fixture, and apply trunk fmt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(db): simplify pass on last-used race fix Share the race hook as tests/db_race_stubs.run_before_first, look tokens up by id in tests, trim duplicated docstrings, and state the handler comment as current behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(db): humanizer pass on last-used handler comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(db): run MariaDB and MySQL sessions at READ COMMITTED MariaDB 11.6+ turns on innodb_snapshot_isolation, so at REPEATABLE READ any transaction that reads a row and then writes it fails with error 1020 ("Record has changed since last read") when another transaction committed to that row in between. READ COMMITTED, PostgreSQL's default, takes a fresh snapshot per statement and removes the whole class of failures. A server logging binlog_format=STATEMENT refuses InnoDB writes below REPEATABLE READ, so its sessions keep the default and log a warning once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(auth): skip last-used and last-active writes inside the debounce window Client-token auth bumped the token, the device and the user on every request, the user with an undebounced UPDATE plus a re-SELECT. The token's loaded last_used_at now gates the token and device bumps, and set_last_active checks the loaded last_active and bumps through a debounced conditional UPDATE, so a request inside the window writes nothing and takes no row lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> |
||
|
|
c6b5f0ae11 |
fix(platforms): count only the roms the caller can see in rom_count and fs_size_bytes (#5313)
* fix(platforms): count only the roms the caller can see in rom_count and fs_size_bytes Platform.rom_count and fs_size_bytes are column properties over every rom row on the platform, and the platform endpoints only filter hidden platforms. So the platform header's "In library" count and "On disk" size included roms hidden from the caller (directly, or by an age limit), while the gallery left them out. Server Stats was off the same way: its per-platform metadata coverage divides /api/stats' visibility-filtered match counts by the unfiltered rom_count, so a restricted user saw coverage too low and platform counts and sizes too high. For a restricted caller, the list, detail and update endpoints now subtract the totals of the roms RomVisibilityFilter hides (DBStatsHandler.get_hidden_rom_totals_by_platform, next to the other per-platform aggregates). Direct hides are matched by primary key, so a few hidden roms cost a few lookups rather than a pass over every rom on the platform. Admins and other unrestricted callers keep the model's values and skip the query. On a generated library of 50 platforms and 100k roms (MariaDB), the platform list takes ~44 ms; this adds ~4 ms with 100 roms hidden, ~44 ms with 5,000, and ~60 ms with an age limit (min_age isn't indexed, so that case scans the platforms' roms). Fixes #5312 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(platforms): read the hidden roms' totals in the platform query Addresses Greptile's review of #5313: - Counts can become negative: the hidden totals came from a second query, so a rom added between the two could be subtracted without having been counted. They now come from a grouped subquery outer-joined into the statement that computes the full totals, so both read one snapshot (on PostgreSQL's READ COMMITTED too, which a shared transaction wouldn't give). - Counting rules live in endpoints: the endpoint helper is gone. get_platform and get_platforms take the caller's RomVisibilityFilter (unrestricted by default) and return platforms with the visible totals; DBStatsHandler.get_hidden_rom_totals_by_platform is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(platforms): code-review fixes for visible platform totals - Re-read rows with populate_existing so a shared session never subtracts twice - Narrow the hidden-totals subquery to the one platform get_platform reads - Re-read after update only for restricted callers, and 404 instead of leaking full totals - Test the update endpoint's restricted totals and the shared-session read Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(platforms): simplify pass on visible platform totals Gate the row clause in one condition with a why comment, fold the MariaDB narrowing reason into the docstring, and drop restating comments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(platforms): count only visible roms in /supported and RetroArch listings - Move the hidden-ROM predicate into RomVisibilityFilter.hidden_on_visible_platforms_clause, with the age rule spelled as ranges an index on min_age can serve - get_platforms reads hidden platforms from the visibility filter instead of a second hidden_platform_ids argument - /api/platforms/supported lists a hidden platform as unmatched and counts only the caller's ROMs on the rest - RetroArch WebDAV skips a platform whose ROMs are all hidden from the caller Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(roms): index platform_id, min_age, fs_size_bytes for age-limited totals On a 73k-ROM copy of a real library (MariaDB 13), GET /api/platforms for an age-limited user went from 208 ms to 55 ms: the hidden-totals aggregate is now an index-only scan instead of a full scan of the wide roms rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> |
||
|
|
60703be09c |
chore(platforms): split arcade aliases into per-emulator-family slugs (#5273)
* feat(platforms): split arcade aliases into per-emulator-family slugs Give MAME, AdvanceMAME, FBNeo, FBA, Daphne, Singe and the arcade boards that need their own emulator (NAOMI/NAOMI 2/NAOMI GD-ROM, Model 2/3, Hikaru, Triforce, Lindbergh, Namco System 246/3xx, Gaelco, ...) their own slugs with verified provider IDs. Providers without a dedicated entry fall back to their Arcade platform via arcade_fallbacks(). MAME-only boards (CPS1-3, System 16/32, Model 1, Namco 22) stay aliases of arcade. Refs #5272 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(platforms): code-review pass on arcade slugs - Retry IGDB on unmatched scans for every platform IGDB resolves, not just slugs in IGDB_PLATFORM_LIST. - Resolve config binding/version values through the alias table, so a binding to a retired slug (cps2, model1, ...) still lands on a platform. - Alias the Batocera `typex` folder to type-x. - Build provider id->slug reverse maps before merging Arcade fallbacks. - Share one MAME title lookup between base_handler and libretro. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(platforms): simplify pass on arcade slugs - Alias the three RomM-keyed IGDB versions inside IGDB_PLATFORM_VERSIONS, dropping IGDB_VERSION_SLUGS and _version_slug. - Derive EmulatorJS arcade entries from ARCADE_SET_PLATFORMS. - Remove the unused provider id->slug reverse maps, so the Arcade fallback merge no longer has an ordering constraint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(platforms): humanizer pass on arcade slug comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(platforms): settle arcade slug review decisions - Migration 0154 moves platforms still on a retired MAME-only board slug (cps1-3, model1, system16, system32, system-32) to arcade, so no row carries a slug the enum no longer has. - MAME shortname expansion keys off the RomM slug via MAME_SHORTNAME_PLATFORMS instead of per-provider arcade ids, so Daphne, Singe, Type X and Lindbergh sets are no longer read as MAME sets. Neo Geo now expands at ScreenScraper too, as it already did at IGDB and Moby. - fba offers fbneo before the FinalBurn Alpha CPS cores. - AdvanceMAME leaves the WebRcade feed; EmulatorJS and WebRcade share PLAYABLE_ARCADE_SET_PLATFORMS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(platforms): code-review pass (xhigh) on arcade slugs Verify arcade-board BIOS files against the known list's arcade entries, and make migration 0154 match retired slugs case-insensitively. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(platforms): simplify pass on arcade slugs Apply IGDB family overrides once in get_platform instead of on each return path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(platforms): use a slug with no shipped icon singe now ships an icon, so the no-icon prefetch test needs a slug that never will. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(platforms): add a teknoparrot arcade slug TeknoParrot runs PC-based arcade boards outside the MAME/FinalBurn family, so its folder gets its own platform (RetroBat and ES-DE both use `teknoparrot`). Providers fall back to their Arcade entry, MAME shortname expansion skips it, and it gets a placeholder icon copied from `arcade`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(platforms): give each arcade-family icon its own marquee title Redraws the ARCADE marquee on the copied cabinet icons with each platform's name, in the Bungee typeface with the original inline and extrusion styling. Sega boards use Sega blue, Namco systems Namco red, and Type X Taito blue; the rest keep the original amber. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(platforms): code-review pass (xhigh) on arcade slugs Neo Geo BIOS lives under arcade in the known BIOS list, so map neogeoaes and neogeomvs there too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(platforms): simplify pass on arcade slug tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> |
||
|
|
aae48728e5 |
fix(metadata): read names from {id, name} facet entries in recommendations and ROM responses (#5249)
* fix(recommendations): handle named metadata objects in facet tokens * fix(recommendations): pr-ready step 2 (code-review): skip non-list columns, base role fallback on usable names Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(recommendations): pr-ready step 3 (simplify): type facet params as object, trim redundant test cases Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(recommendations): pr-ready step 4 (review-polish): keep the extract_tokens test prefix Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(roms): read names from metadata objects in filter values and ROM responses Share the facet name cleaner as utils.facets.facet_names, and run it in the filter-values reader, RomMetadataSchema, and over every list[str] key of the provider metadata blobs, so an {id, name} entry no longer fails /api/roms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(roms): clean name lists in raw metadata edits, reject non-object JSON parse_raw_metadata now runs the provider blob's list-of-names keys through facet_names before storing it, so {id, name} objects stop landing in the database, and answers 422 when the JSON is not an object. Manual metadata keeps its strict adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
89607cd22c |
chore: Library support for zelda classic games (#5214)
* feat(platforms): add Zelda Classic (zc210) engine support Recognise Batocera/REG-Linux zc210 quest folders as the zelda-classic platform so .qst libraries scan as a first-class engine platform, matching existing fantasy-console/engine precedents like TIC-80 and WASM-4. Co-authored-by: Cursor <cursoragent@cursor.com> * chore(platforms): drop placeholder Zelda Classic icons Use RomM's default platform icon until a properly licensed asset is available. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(setup): identify FS alias platforms in library wizard The setup UI matches on-disk folders by exact fs_slug against supported_platforms, so aliases like zc210 never matched zelda-classic. Merge resolved filesystem platforms into the setup response. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(platforms): also alias zc250 to Zelda Classic EmulatorJS documents both zc210 (2.10) and zc250 (2.50) cores for .qst quests; accept either folder name as Zelda Classic. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(setup): reuse listed folders when merging FS aliases get_filesystem_platforms was walking the library again outside the setup endpoint's error guard, so a folder-list failure could still 500 /api/setup/library. Pass the folders already read instead. Co-authored-by: Cursor <cursoragent@cursor.com> * revert(setup): drop setup-wizard FS alias merge from this PR Keep Zelda Classic platform aliases (zc210/zc250) without changing /api/setup/library behavior. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> |
||
|
|
3a79911b2f |
Revert "feat: classify ROMs by release type (homebrew, hack, translation, ...) (#5363)" (#5365)
This reverts commit
|
||
|
|
08acaa9ea9 | feat: classify ROMs by release type (homebrew, hack, translation, ...) (#5363) | ||
|
|
552ac3a393 |
fix(platforms): share provider entries across duplicate platform slugs (#5359)
* fix(platforms): share provider entries across duplicate slugs and rename system-32 Three consoles have two RomM slugs, each used by different providers, so a library folder only matched the providers that knew its spelling: vc-4000 / interton-vc-4000, apple-pippin / pippin and tandy-vis / vis. DUPLICATE_PLATFORM_SLUGS lists them once, and fill_duplicate_slugs gives each slug the other's entry in every provider table. pippin and interton-vc-4000 now get an IGDB platform id, and IGDB's family override also applies to a listed duplicate so both VC 4000 slugs stay in the Interton family. The system-32 slug mapped to Namco System 22 in ScreenScraper and LaunchBox, easy to confuse with Sega System 32 (system32). It is now namco-system-22. Folders and config bindings named system-32 still resolve to it, and migration 0154 renames existing platform rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh * fix(platforms): resolve bindings to a renamed slug back to their folder resolve_platform_slug already maps a binding to system-32 onto namco-system-22, but resolve_fs_slug compared the raw binding with the new slug, so a moved folder bound to the old slug was never found. Both now go through the same renamed-slug lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh * fix(platforms): drop the system-32 slug backfill migration Every scan resolves a platform's slug from its folder again, so the next scan renames system-32 rows through the renamed-slug alias without a migration, as the backend guide asks for normalizations the parser now handles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh * chore(platforms): reword two comments so the product isn't the actor Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh * revert(platforms): leave system-32 to the arcade slug split rommapp/romm#5273 retires system-32 as an alias of arcade and resolves aliases in config bindings in both directions, which covers what the namco-system-22 rename and the renamed-slug lookup did here. This PR now only shares provider entries across duplicate slugs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
26dff477d7 |
fix(auth): bound new client tokens by the caller's scopes and stop delegates removing admins (#5346)
* fix(auth): bound new client tokens by the caller's scopes and stop delegates removing admins - Creating a client token, approving a device, and regenerating or pairing an existing token now check against the scopes of the credential making the request rather than the whole account's. A narrow client token can no longer mint, or recover the secret of, a broader one. Session and basic auth carry the account's scopes, so they behave as before. - Deleting an admin requires the caller to be an admin, mirroring the existing rule for creating one, since users.write can be delegated. - Editing another user requires the users.write scope on top of the admin role, so an admin's me.write-only token can't change other accounts. - own_only is rejected (422) on grants and overrides for entities with no owner (platforms, roms, firmware, users, tasks, logs), where it silently meant "all". The catalog exposes the ownable entities and the permission matrices only offer "own" on those. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(permissions): keep owner-less own_only grants' access on save Addresses Greptile review on #5346: - An own_only delete grant on an entity with no owner allows nothing today (delete has no coarse scope and the fine check runs with owned=False), so it is now dropped from group grants, or turned into a revoke for overrides, instead of being saved as full delete access. The matrices show it the same way. - The group dialog no longer saves when the permission catalog failed to load, which would have stripped every own_only grant. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(auth): require users.write in the credential to act on another user (pr-ready: code-review) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(auth): share client token effective scopes and canOwn (pr-ready: simplify) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(permissions): tighten grantEffect docstring and matrix comment (pr-ready: review-polish) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(auth): make user, token and streaming admin rules consistent - Acting on another user (edit, delete, RA refresh) needs users.write in the credential, and only admins may target an admin or grant the admin role. One assert_admin_for_admin helper now backs add_user, invite links, update, delete and admin token revocation. - Re-issuing a client token's secret (regenerate, pair) needs every scope it stores; deleting one needs every scope it currently grants, so a narrow token can't remove a broader sibling. - Streaming admin overrides need users.read or users.write in the credential, not just the admin role. - Migration 0154 rewrites stored own_only grants and overrides on owner-less entities to the access they already gave, so the frontend normalisation and the catalog save gate are gone. - own_only is no longer rejected on revoke overrides. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
e232a52656 |
fix(docker): boot when the container runs as a non-default UID (#5189)
* fix(docker): boot when the container runs as a non-default UID Unraid runs the container as 99:100, which can't write to the image's /romm (owned by 1000, mode 755), only to the mounted subfolders. The PSP pending dir at /romm/cache/retroarch_sync was created at import time, so every gunicorn worker failed to boot. - Buffer pending PSP save files under the user's assets folder (assets/users/<user>/retroarch/psp_pending/), beside the other RetroArch Cloud Sync files and outside the client-reachable blob categories. - Move the zip and rom-converto download caches to /tmp/romm/cache, and point nginx's internal /cache/ alias there. - Put gunicorn's control socket in /tmp/gunicorn instead of $HOME/.gunicorn, since HOME is / for that UID. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(docker): honor ROMM_TMP_PATH for caches, explain an unwritable sync folder - The download caches live under $ROMM_TMP_PATH/cache when it's set, so installs with a small Docker disk (Unraid's docker.img) can point them at a share. The entrypoint exports the same path for nginx's /cache/ alias. - With ENABLE_SYNC_FOLDER_WATCHER on and /romm/sync not writable, /init warns and skips the watcher instead of dying on mkdir under errexit. - The compose example lists the /romm/sync mount the sync features need. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): cover reading back and clearing buffered PSP files Addresses Greptile's review on #5189. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): apply code-review findings to PSP pending buffer Remove the emptied psp_pending folder after a merge, define the sync folder path once in init, update the architecture doc's PSP and blob locations, and drop a stale .gitignore entry. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(sync): apply simplify findings to PSP pending cleanup Clear the buffered folder with remove_directory, let the startup check own creating the sync folder, and reword the test fixture docstring. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): cap buffered PSP files and drop them on delete Buffered files for an unresolved save folder now count against the bundle limits, so a folder can't fill the assets share and then fail every merge once it resolves. A DELETE also removes the buffered copy, so a deleted file isn't merged back when the folder resolves. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(docker): check the sync folder for push-pull sync too ENABLE_SYNC_PUSH_PULL keeps SSH keys and device saves under /romm/sync as well, so an unwritable folder now disables it with the watcher and warns at boot instead of failing when the task runs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(docker): strip whitespace from env vars like the backend does The backend strips every variable it reads, while the init script and nginx templates used raw values, so a padded ROMM_TMP_PATH sent nginx's /cache/ alias somewhere the backend never writes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(config): drop the CACHE_BASE_PATH comment Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(docker): say which backend config strips env whitespace Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * revert(docker): drop the entrypoint env whitespace trimming Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): apply pr-ready code-review findings Gate push-pull on its SSH keys path rather than a writable sync folder, accept the same truthy values as the backend, and clear only the merged PSP pending files so another worker's buffered file survives. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor: apply pr-ready simplify findings Share one truthy pattern across init's flag checks (the watcher gates now accept the same values as the backend), disable gunicorn's unused control socket instead of placing it, derive the converts redirect from its own cache path, and factor the unknown PSP folder in tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(docker): apply pr-ready humanizer pass to the sync mount note Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(fs): create handler base folders on first write, skip leftover temp files FSHandler no longer mkdirs its base path when constructed, so a module-level handler rooted at an unmounted or unwritable folder can't take down boot; every write path already creates its parent folders. Blob listings skip .romm_tmp_ files a crashed write left behind, so they are never merged into a PSP bundle or advertised in the sync manifest. The prefix now lives in one TEMP_FILE_PREFIX constant. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
38dfb208f0 |
fix(streaming): file RetroArch streaming exits as raw saves (#5174)
* fix(streaming): keep foreign saves offered when the import-spec check fails A broker that misses the 5 s import-spec deadline used to read as "imports nothing": the Saves tab vanished and foreign picks were refused with "Save is not a restorable archive". Keep the last good answer in Redis so every worker can fall back on it, cache 404s for five minutes instead of forever, answer a pick that can't be checked with a retryable 503, and refetch the streaming config whenever the Stream page mounts. * fix(streaming): code-review fixes for the import-spec fallback Hold a fallback answer for 10 s so one claim's checks don't each wait out the broker timeout, read the stored answer back through the broker response parser, and warn about a pre-import broker once per worker instead of at every cache expiry. * refactor(streaming): simplify pass on the import-spec fallback Make ImportSpecUnavailable the 503 itself so the save and state pickers no longer convert it by hand, and store the broker's own response body as the last answer instead of rebuilding its shape. * chore(streaming): review-polish on the import-spec fallback Trim the cache comments and the exception docstring, fit the 503 detail within the line limit, and annotate the fresh-worker test dict for mypy. * docs(streaming): humanizer pass on import-spec comments and test docstrings * fix(streaming): tell lasting import-spec failures from passing ones Only timeouts, connection errors, 5xx and 429 fall back to the broker's last answer. A refused request (401, other 4xx) or a reply RomM can't read caches no imports for 30 s and logs an error, so a pick gets a refusal instead of an endless retry. A 404 from a broker that answered before uses that answer, since it is likelier a restart behind a proxy than a downgrade. * fix(streaming): ask for a retry when a picked state can't be checked An older save with the newest state resumes the pick only through an import, so an unanswered import-spec check now returns the 503 instead of launching from the older archive's own state. * fix(streaming): share an in-flight config request App load and the Stream page both fetch the config; two requests could land out of order and leave the older answer in place. (Stability item 5.) * fix(streaming): hold the resume picker until the fresh config lands What the broker imports decides which saves and states are on offer, and the app-load config can predate its answer. The panel shows a spinner until the Stream page's own refetch settles, so a pick can't vanish under the player. (Stability item 4.) * fix(streaming): ask every platform's broker at once on /config The checks ran on the default thread pool (cpu+4 threads), so a broker serving more platforms than that cost one timeout per wave: 10.7 s for 14 platforms on a 6-CPU dev box with a silent broker. The Stream page's picker now waits on /config, so the checks get a pool of their own. * fix(streaming): address Greptile review on the import-spec fallback - Play waits on the fresh config with the resume picker, so it can't send a preselected state the player can't see yet. - The streaming store gets a reset() for logout, and a config reply asked for as the previous account is dropped instead of landing in the next one. - The configFresh write after the refetch checks useIsAlive(). - Trimmed the require_import_spec docstring, the configFresh comment and the /config pool comment to the house length. - Declined: a worker-wide pool for the /config checks. Each request's threads end within the broker timeout, and a shared bounded pool would bring back timeout waves under concurrent loads. * fix(streaming): share /config broker checks across requests Addresses Greptile's re-raised finding on #5174 that each /config request opened its own pool of up to 64 threads, so overlapping page loads during a silent broker multiplied the worker's threads. - The checks run in one worker-wide pool, and a check already in flight for the same container and platform is joined rather than asked again, so concurrent page loads hold no more threads than one does, with no queued-timeout waves. - Callers await the shared run through asyncio.shield, so a request that disconnects doesn't cancel the check others are waiting on. * fix(streaming): file a RetroArch exit's save raw and boot the newest save A RetroArch exit holding one .srm and its states is no longer stored as a .saves.zip: the .srm is filed bare under the core's emulator name with a timestamped name, and each state goes through the state store. Exits with more than one save, a memory card, or unlabelled members still keep the zip. A launch with no pick now boots the newest save, raw or zip. A newer bare .srm goes through the broker's save import when the broker accepts one, and the launch screen defaults to the same save. * fix(streaming): keep the exit zip when a raw save can't be filed safely pr-ready step 2 (code review). - Keep the zip for a core that isn't one plain folder name, a malformed manifest kind, a member that fails to unpack, or a broker that doesn't import saves. - Fall back to the newest archive when the default raw save fails to import. - File exit states oldest first; one unreadable stored state no longer drops the rest. - Rename locals that shadowed the archive module; fix a test return type and a stale comment. * refactor(streaming): simplify the default save comparison pr-ready step 3 (simplify): default_save reuses _newest's ordering, and newestSave takes the first match in the newest-first list. * docs(streaming): trim the raw-save docstrings pr-ready step 4 (review-polish). * fix(streaming): rank saves by their last write and read .ZIP as an archive The web player writes into its existing save row, which only moves updated_at, so ranking by created_at let a stream with no pick boot an older streaming zip over newer web-player progress. The backend default and the launch screen now rank by updated_at, and the picker dates rows by it. Upper-case .ZIP saves are now read as archives on both sides, to match the web player's case-insensitive guard. * feat(states): hash states so duplicate checks skip reading files Adds states.content_hash (migration 0149), filled on every state write: streaming capture, the states upload and update endpoints, the scan and the RetroArch sync push. The streaming duplicate check compares hashes and falls back to reading the file for rows stored before this, which are not backfilled. * fix(streaming): leave an untouched default off the claim and skip missing saves Review items 1 and 2: a default sent as a pick bypassed the zip fallback, and a save marked missing could become the newest. * fix(streaming): code-review fixes for raw exit filing and state hashing pr-ready step 2: keep the zip when a state can't be filed, don't treat a missing state file as a duplicate, fall back to the native archive when a defaulted save fails, hash off the event loop, count filed states as new. * docs(streaming): review-polish, trim the newest-save comment * fix(streaming): bind the background exit pull's states to the swapped disc Decision 1: the exit save job filed states without the session's disc id, so on a multi-disc game its copy could lose the disc binding. The second copy is still dropped by the hash dedupe. * fix(streaming): keep the exit zip when one of its states fails to store Decision 2: a state that threw on store was logged and lost, since the zip holding it was dropped. The zip holds the same .srm, so booting it as the default loses nothing. * fix(sync): keep updated_at when RetroArch sync flags a vanished save or state * fix(streaming): record a legacy state's hash when dedupe reads its bytes * fix(streaming): file a RetroArch exit's auto state raw instead of keeping the zip The auto state now goes into the state history under its own capture stamp, so an exit carrying one files its .srm raw like any other. It is never hydrated, and a resume pick of it is refused, since the broker would file it into its numbered working slot. * fix(streaming): hydrate the newest state still on disk A newer row sync flagged as gone from disk made hydrate push nothing. It now skips such rows the way the save picks already do. * docs(streaming): note the auto-state refusal in resolve_resume_state * fix(streaming): resume a RetroArch auto state like any other state The broker files any pushed state into its working slot, so .state.auto reads as slot 0 like a bare .state. Hydrate and the resume pick now push it instead of skipping or refusing it. * fix(streaming): address Greptile review on raw RetroArch exits - A default .srm the broker refuses at activate now boots the newest native archive instead of failing the launch. Only a default save that rode the import alone falls back; a hand pick still fails. - Exit states the history hasn't seen are filed just under the next state it already holds, so an older slot no longer heads the history over the exit capture teardown filed first. - A raw exit save is skipped only when it matches the newest usable save, so returning to an older save records the play, and a match on a row whose file is gone no longer deletes the new copy. - Stream.test.ts clicks the rendered play button instead of casting the view model to call onPlay. - Trim the raw-exit docstrings to one sentence. * fix(streaming): reserve a free version name for a raw RetroArch exit save Addresses Greptile: the exit's .srm took a second-resolution tag without checking whether another save held that name, so it could overwrite one. Also compares updated_at naively in the mark-missing test, which failed on PostgreSQL's UTC-aware column. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(streaming): file each RetroArch exit state on the disc it was saved on Addresses Greptile: every state in the exit archive took the session's final disc, so a hotkey slot saved before a swap resumed on the wrong one. The session now keeps each swap with its time, and a session that ran more than one disc files each state by its archive timestamp. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
3b8eabdb77 |
feat(sync): sync RetroArch Cloud Sync saves through save slots (#5170)
* feat(sync): sync RetroArch Cloud Sync saves through save slots RetroArch saves were unslotted and overwritten in place, so they never reached the slot-based sync the native clients use, and a bad upload replaced the only copy. A save path now serves the newest slotted version for its ROM, core and extension, from any slot, under RetroArch's own file name. An upload adds a version to that slot (or autosave), skips unchanged bytes, and prunes to MAX_SAVES_PER_SLOT. A delete removes every save the path covers, so none resurfaces on the next sync. Unslotted saves keep serving until the first slotted upload; PSP bundles and states are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): lock RetroArch save uploads and prune per core and extension Addresses Greptile's review on #5170: - Move the RetroArch save upload into sync_handler.store_save_version, leaving the endpoint to validate and map the result to a status. - Hold a Redis lock per (user, rom, core, extension) across the lookup, write, scan and row update, so concurrent same-second uploads never file two rows over one tagged file. A lock timeout answers 503. - Prune only the uploaded path's core and extension in the slot, so another core's or a .rtc's current save is never dropped. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): pr-ready code-review fixes for RetroArch save slots - Scope an extensionless prune to dotless file names, since every name ends in an empty extension. - Treat only NULL slots as unslotted in the manifest, matching the query it replaced and the PSP bundle lookup. - Share one helper for the slot versions a RetroArch path covers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(sync): pr-ready simplify pass for RetroArch save slots - Scope a slot prune by save ids, so the versions a RetroArch path covers are decided once in Python instead of again in SQL. - One newest-per-key helper for states and save versions, and resolve_save_by_slot reuses it. - A canonical_save_file_name helper next to the state one. - The upload builds its tagged name once, checks its length in the handler, and finds a same-second version in the list it already loaded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(sync): pr-ready review-polish pass Drop a comment the canonical_save_file_name helper now says. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): map RetroArch saves onto autosave lineages with unique version names - Only RetroArch's .srm goes through slots, as the autosave versions of its ROM and core. Companion files such as .rtc stay single unslotted saves, so a slot never offers a clock file as the save. - RetroArch reads, writes and deletes in autosave only, leaving named slots alone. - Every slot prune, web uploads included, is scoped to the uploaded save's lineage (emulator and extension), so one core's uploads never drop another's only save. - The manifest lists the newest version under the client's spelling of the game when it still names the ROM. - reserve_version_name moves a taken tag on a second and claims it in Redis, so same-second, concurrent or repeated-hour uploads from either endpoint never share a file. The RetroArch lock and its 503 go. - The manifest reads only the newest version per lineage, through one window query. - An upload is hashed before it is written, so an unchanged re-send writes nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): seed the client-spelled save instead of uploading it Uploading TEST_ROM.srm only resolves to the test_rom ROM under MariaDB's case-insensitive collation, so the test 409'd on PostgreSQL. Seeding the version directly still checks that the manifest keeps the client's spelling of the game. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): resolve RetroArch saves to ROMs case-insensitively on PostgreSQL Cloud Sync matches a save's game name to a ROM's fs_name_no_ext. MariaDB's collation ignores case, but PostgreSQL compared exactly, so TEST_ROM.srm never reached the test_rom ROM. PostgreSQL now compares lowercased names, served by a new expression index (0150), and the endpoint test uploads the differently-cased name again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): address Greptile review on RetroArch save slots - add_save derives the prune lineage from the tagged name it stores, so a dotted upload such as game.rev.srm is counted against its own versions. - Deleting a RetroArch .srm path also removes unslotted saves in that lineage spelled in another case, which the manifest hid behind the autosave head and PostgreSQL's exact match left behind. - reserve_version_name looks up existing versions off the event loop. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
7b1028bedd | feat: search platforms by slug, abbreviation and alternative names (#5107) | ||
|
|
b23bc79b46 | feat(launchbox): scrape box front, back, spine and 3D box art (#5129) | ||
|
|
812e0bdb28 | fix(patcher): read the patcher's report from its last JSON line; test the patch endpoint (#5120) | ||
|
|
9e4b080403 | fix(metadata): one UTC helper for release dates, a lint rule against local-time parsing, and Flashpoint tests (#5114) | ||
|
|
ef3128e154 | Hide ROMs above a user's or group's age limit (#5081) | ||
|
|
1dcda140e2 | fix(rom): keep a disc an .m3u lists in place when promoting to a folder (#5076) | ||
|
|
655976faa9 | feat(soundtrack): play SPC, VGM, VGZ and GYM soundtracks in the browser (#5079) | ||
|
|
c63f44133d |
perf(config): read config.yml values with a plain dict walk (#5071)
* perf(config): read config.yml values with a plain dict walk pydash.get parses the path and probes every container type on each call, and the scan reads config values per rom. A dotted-path lookup over the parsed YAML dicts returns the same values. * fix(config): address Greptile review Drop the _config_get docstring, which restated the four-line dict walk below it (AGENTS.md comment discipline). * refactor(config): move nested config lookup to utils.database as get_nested Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
10865b8663 |
perf(roms): faster smart collection and filter value queries (#5069)
* perf(roms): stop MariaDB rescanning the library for smart collections MariaDB plans the smart collection membership IN (subquery) as a semi-join that rescans every rom per page query. A NO_SEMIJOIN hint keeps it a plain subquery; other dialects don't emit the hint. * perf(roms): parse each distinct filter value list once The filter dropdown query decoded every JSON column of every row. The columns are now read as text, deduplicated, and each distinct list is parsed once. PostgreSQL decodes JSON in the driver, so its lists are merged as returned. * test(roms): cover repeated filter value lists in pr-ready code review * refactor(roms): pr-ready simplify pass * style(roms): pr-ready polish * fix(roms): address Greptile review Fold filter value rows in batches of 5000 instead of materializing the whole result, keeping the parse-each-distinct-list-once dedup across batches, so /api/roms/filters no longer holds one row per ROM in memory (Greptile: filter requests retain every row). The repeated-lists test now runs with a batch size of 2 to cover the cross-batch path. * fix(roms): pr-ready code review fixes - Cast filter JSON columns to text in SQL, so PostgreSQL gets the parse-once saving and a scalar JSONB value no longer crashes json.loads - Stream filter rows with yield_per instead of only partitioning - Name the JSON filter columns instead of hard-coding positions - Add optimizer_hint_on_mysql next to force_index_on_mysql, with tests - Make the repeated-lists test span batches regardless of row order Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(roms): pr-ready simplify pass Collect each filter column's distinct JSON texts and parse them once at the end, and key the JSON filter columns by their RomFiltersDict field so the positional unpack and per-field return go away. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * style(roms): pr-ready polish Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
b1f4ac4888 |
fix(db): keep iterated query results away from the cyclic GC (#5068)
* fix(roms): read filter values with .all() so the GC never frees the cursor Looping over the filter-values Result directly makes SQLAlchemy 2.1 memoize an iterator closure that captures the Result, which puts the CursorResult, its execution context and the mariadb cursor in a reference cycle. The cyclic GC then frees them on whatever thread triggers a collection, and under concurrent gallery requests that segfaults the mariadb connector (1.1.14, Python 3.14) inside the pool checkout. .all() never builds that closure, so nothing is left for the GC. * fix(roms): address pr-ready code review * style(roms): pr-ready polish * fix(db): read every iterated query result with .all() The same reference cycle that segfaulted the filter values also hits smart collection matching on every save, the screenshot binding check, playlist and favourite adds, the recommendation reads and the stopword probe. The IGDB related-games stream keeps yield_per and closes its Result with a with block. A source scan test now fails on any Result iterated directly. * fix(roms): address Greptile review Keep gc.garbage entries that predate the filter-values cursor test: only the objects this test collects are inspected and removed, so a runner that already saves garbage keeps its list intact (Greptile, test_rom_facets.py). * pr-ready: code-review fixes Keep a generator's begin_session open until it finishes, read the streamed IGDB scan by partition, and widen the iterated-Result guard to names, unpacking, yield from and iterating methods. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * pr-ready: simplify Share the app-source AST scan between the two guard tests, fold the generator session's two branches into one nullcontext, and drop the call-site comment the guard test already carries. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(db): flag iterated legacy session.query() results Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
05bf29fe09 |
feat(converto): read per-file title ids with rom-converto during scans (#5031)
* feat(converto): read per-file title ids with rom-converto during scans The title-id half of #5002: rom-converto's info runs fill rom_files.title_id and title_version, sigil fills what rom-converto can't read and keeps owning save targets, and roms in a scan batch share info runs of up to 64 files. A converto_read_at marker lets quick scans backfill files rom-converto has not read yet. converto.scan_metadata (config.yml only) turns it off. The other per-file fields and embedded images stay out until a UI reads them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): name the same-content check that keeps unread title ids Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): queue unread files in one pass over the built rows Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): address Greptile review on #5031 - A file refresh now persists converto_read_at when rom-converto's read confirms a reused row's stored title id, so the file isn't re-read on every refresh. - RomConvertoService.read_infos splits its paths into info runs of at most INFO_BATCH_SIZE, so a rom with many files can't send them all through one run. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): apply code-review fixes - A stored file title id counts as rom-converto's only once rom-converto has read the row, so a stale sigil id can't override a fresh extraction. - Fresh hashes decide whether unread title ids still describe a file, ahead of a size and mtime a copy can preserve. - One rom's failed candidate listing no longer aborts its scan batch. - The info paths file's cleanup can't raise out of read_infos. - _rom_file_order sorts by Path like _TitleIdSource.order. - Restored the in-place reconcile test for _identify_rom. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): apply simplify pass - sync_rom_files reads 'rom-converto read this pass' off converto_read_at instead of an inspected set threaded through ParsedRomFiles, FSRom, the scan socket and the refresh. - One _converto_may_read check serves the scan and the batch candidates. - converto_candidates reuses _list_rom_dir, validates paths off the event loop and is best-effort itself, so the scan socket gathers it plainly. - get_rom_files builds rom-converto paths from the validated rom dir instead of validating each file again. - _rom_level_identity returns early on sigil's extraction. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(converto): apply review-polish pass Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): drop the shared info batch Sharing rom-converto info runs across a scan batch saved about 2 ms per rom (one process start) in exchange for a second directory walk per rebuilt rom, the RomConvertoInfoBatch bookkeeping and the scan socket wiring. Each rom now reads its own files; read_infos still caps a run at INFO_RUN_MAX_FILES. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): name the rom-converto columns inline Drops ROM_FILE_CONVERTO_COLUMNS and ROM_FILE_CONVERTO_KEPT_COLUMNS, so _copy_scanned_columns keeps master's frozenset keep_when_unset. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
fb61cbe882 |
feat(search): Search provider aliases through search_titles and drop generated_search_aliases (#5003)
* Search on search_titles and drop generated_search_aliases The gallery filter matched provider aliases through a generated column built from the JSON text, so escaped characters (MariaDB's \uXXXX storage, tabs, quotes) were out of its reach, and ranking already reads the folded titles in `search_titles`. Point the MariaDB FULLTEXT index and the PostgreSQL trigram index at `search_titles` and drop the generated column. Migration 0147, not yet released, makes the swap; its downgrade rebuilds 0146's column and index from a frozen copy of their SQL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Rebuild roms after the search titles backfill on MariaDB Filling `search_titles` grows every row in place, which leaves InnoDB's pages split and slowed the FULLTEXT search by 10 to 25 ms on 40,000 ROMs. One table rebuild after a backfill that filled rows restores it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * pr-ready code review: describe the alias search test case as it stands Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * pr-ready simplify: read the legacy column name off the 0147 migration Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * pr-ready review-polish: describe the rebuild as the code does it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Freeze 0147's provider list and always rebuild roms on MariaDB - The backfill and the downgrade's copy of 0146's column read a frozen provider list instead of `ALTERNATIVE_NAME_SOURCES`, so a later provider can't change what this revision selects or rebuilds. - The table rebuild runs on every MariaDB/MySQL upgrade: a run that stopped after the fill but before the rebuild left nothing to fill on retry. - Two comments describe why, not what the migration replaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Fold 0146 and 0147 into one search titles revision Neither revision has shipped, so `0146_roms_search_titles` takes the roms table from 0145 straight to `search_titles` and its search index, and `generated_search_aliases` never exists. The search indexes are dropped first, so the column is added and filled with no index to maintain, and the index is built once over the filled rows. Databases on a nightly that ran either old revision need resetting to 0145 before upgrading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Keep the search titles migration under 0146's revision ID The folded revision now rewrites 0146_roms_search_aliases in place rather than adding a new ID. A nightly database that already ran the old 0146 or 0147 still needs resetting to 0145 before upgrading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Say why 0146 adds search_titles ahead of ensure_roms_columns Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
819811b155 |
feat(converto): library format settings and "Download as" on the game page (#5000)
* feat(converto): integrate rom-converto for title id extraction and download conversion * feat(converto): add conversion settings UI with per-platform format policies * fix(converto): read conversion targets from the backend and translate the settings page * fix(docker): ship rom-converto in the production image Only the dev Dockerfile installed the binary, so the integration could never enable on a released image. Fetch the same pinned, checksummed musl build in a dedicated stage and copy it next to RAHasher. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): skip the update check and batch info calls The CLI asks api.github.com for a newer release on every run unless told not to, so pass --no-update-check on each invocation. Inspect a rom's files in one `info --paths-file` run instead of one subprocess per file, and read the inspectable extensions from the capabilities manifest so scans skip files info cannot recognize. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(scan): keep sigil authoritative for title ids rom-converto ran first and overrode the ids sigil read. Sigil now runs first and records its per-file ids; rom-converto only fills files sigil left unset, on new or changed files, in one batch. Restore the base-id selection for sigil extractions on every platform, as on master. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(downloads): make conversion opt-in and bound the cache The download endpoint returned a converted file to every client once a platform had a target, including the browser player and apps that check hashes against RomFile. Conversion now needs ?converted=true. A pre-warmed copy is served whatever its size; the in-request size cap only gates starting a conversion. ROM_CONVERTO_CACHE_MAX_SIZE_GB (default 20, 0 unbounded) caps the cache: conversions and the pre-warm task stop when it is full, and cleanup evicts the least recently served copies. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(types): regenerate frontend types for the converto schema Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): address code-review findings (pr-ready step 2) - Fall back to rom-converto's stored ids only when it ran this pass, in disc order, so a rescan that skipped extraction keeps sigil's save target - Persist per-file title ids that extraction writes onto reused rows - Only authenticated callers may start an in-request conversion; past a 240s deadline serve the original and let the conversion finish into the cache instead of nginx returning 504 - Treat a probe OSError or timeout as a failed probe; kill the subprocess when the caller is cancelled - Give the pre-warm task the scan timeout and report progress in the ConversionStats shape the task UI reads - Reuse zip_cache constants, walk the cache off the event loop, tolerate files vanishing mid-cleanup, and trim long comments Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): simplify conversion code (pr-ready step 3) - Move the converted-download policy (target lookup, cached-first, sync size cap, deadline) from the endpoint into utils/conversion_cache and share conversion_target with the pre-warm task - Share one path lookup between get_cached_converted and get_or_convert; the pre-warm walks the cache once and tracks a running byte budget instead of walking it twice per rom - One normalize_platform_formats beside TARGETS_BY_PLATFORM for the config loader (via _validated_platform_map) and the settings endpoint; update_converto_settings takes a ConvertoConfig and is written back with dataclasses.asdict - read_infos owns its never-raise contract, so the scan drops its blanket except; drop the unused RomConvertoInfo.kind and error attributes - Sort files for the rom-converto identity only when it is used; stat each cached file once during cleanup Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(converto): trim comments (pr-ready step 4) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): convert on first download instead of pre-warming A library pre-warm fought the TTL: cleanup dropped every copy nobody downloaded within a day. Remove the Convert library task and convert on demand only. Files over ROM_CONVERTO_MAX_SYNC_SIZE_MB now start their conversion in the background while the original is served, so the next download within the TTL gets the converted copy at any size. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): drop decrypt and encrypt download targets Downloads now only change a rom's container or compression (CHD, RVZ, CSO, NSZ, ...); serving decrypted files is left for a separate decision. NDS and PS3 have no remaining targets. Also note that the conversion concurrency limit applies per process. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): move the cache limits into converto.* cache_max_size_gb and max_sync_size_mb join cache_ttl_hours in config.yml and PUT /api/config/converto_settings, replacing the ROM_CONVERTO_CACHE_MAX_SIZE_GB and ROM_CONVERTO_MAX_SYNC_SIZE_MB env vars, so every eviction knob is edited in one place at runtime. The loader takes its defaults from ConvertoConfig and one table holds each integer's minimum for both the loader and the payload. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): lock conversions with flock instead of a sentinel A conversion now holds a non-blocking flock on its key dir, which the kernel releases if the worker dies. That replaces the .partial sentinel, its 6-hour staleness guess (which a long ROM_CONVERTO_TIMEOUT could outlive), and the rename-aside takeover. Cleanup skips locked dirs, and partial output gets a hidden name so it never counts as a served copy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(converto): parametrize repeated test cases Collapse the per-platform info parsing, operation resolution and converto_active cases into parametrized tests, so a new platform or target is one row. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(scan): run rom-converto first with sigil as the fallback rom-converto reads each rom's new or changed files first, in one batch, and its title ids win. sigil still reads what it can, since it alone provides save targets and Switch content types, and fills the ids rom-converto left unset. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): edit the cache size limits on the settings page * feat(converto): store per-file metadata read by rom-converto during scans * fix(converto): show the labels of the cache settings fields * fix(scan): keep the stored save target when sigil reads nothing * fix(converto): read Xbox 360 disc ids and Wii title versions, store content type as text * feat(converto): save file icons, banners and backgrounds read by rom-converto * chore(converto): bump rom-converto to v0.23.0 * fix(converto): address review findings in the conversion cache, scan metadata and settings * refactor(converto): move per-file metadata out of the conversion PR Scan-time metadata (title ids, the 17 rom_files columns, artwork and converto.scan_metadata) moves to its own PR so its columns land with the UI that reads them. This PR keeps conversion only. The conversion cache no longer has uncompressed_size_bytes to budget with, so a conversion to an uncompressed target reserves a fixed multiple of its input and the cleanup pass after it evicts any overshoot. Co-Authored-By: DevYukine <20647088+DevYukine@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BuuZVVtVPNLRaCjTN9bgQ * feat(converto): let the client pick the download format with ?format= `?format=zso,iso` lists the formats a client can read. The stored file is served whenever its format is listed, even with conversion off, so most emulator clients never trigger a conversion. Otherwise the first listed format with a cached copy is served, then the first one rom-converto can produce. A conversion that outlasts a short wait answers 202 with Retry-After instead of falling back to the original, so a URL never serves two different files and a client never gets bytes it can't read. 406 means no listed format can be served. HEAD reports the same without starting a conversion. This replaces `?converted=true`, the per-platform download target and `max_sync_size_mb`; `cache_ttl_hours` stays config.yml-only. Co-Authored-By: DevYukine <20647088+DevYukine@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BuuZVVtVPNLRaCjTN9bgQ * feat(converto): convert the library in place with a manual task `converto.platform_formats` now names the format a platform's library is stored in, and the new "Convert library" task brings every matched rom to it. Each output is staged in a `.romm_tmp_` directory beside the original, moved into place, and only then are the originals (and a cue's tracks) deleted. Single-file roms take the new name, folder roms keep theirs and get their .m3u entries rewritten, and the file rows refresh, so a rom keeps its id, saves and collections. Only lossless conversions qualify, so xbox (xiso trims the dump) has no library format. Unmatched roms are skipped because a converted file no longer hash-matches a DAT. `/api/config` now carries the library targets and, per input extension, the formats a download can be converted to. Co-Authored-By: DevYukine <20647088+DevYukine@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BuuZVVtVPNLRaCjTN9bgQ * feat(converto): library format settings and "Download as" on the game page The settings page follows the reworked backend: per-platform formats are now the library format the "Convert library" task stores matched games in ("Leave as is" keeps a platform untouched), the scan metadata, cache TTL and max-sync fields are gone, and a "Convert library now" button starts the task behind a typed confirmation, since it deletes the originals. The game's More menu offers "Download as <format>" for a single-file rom when download conversion is on, from the per-extension table `/api/config` exposes. A one-byte ranged GET asks for the format, the UI polls through 202s while it converts, then downloads it; a 406 shows an error. Co-Authored-By: DevYukine <20647088+DevYukine@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BuuZVVtVPNLRaCjTN9bgQ * fix(converto): address code-review findings (pr-ready step 2) Guard the conversion settings route, add it to the user menu, ignore a non-positive Retry-After, drop duplicate Download as clicks, name the game in the persisted error, and tidy the settings page (display-name sort, useUnloadGuard, decimal cache sizes, save snapshot). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(settings): share the config alerts and save bar (pr-ready step 3) Extract ConfigFileAlerts and SettingsSaveBar from the three settings views that copied them, move ScanSettings onto useUnloadGuard, align the retry slot, and flatten downloadFormats, getDownloadFormats and the format poll loop. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(converto): trim comments (pr-ready step 4) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(converto): guard destructive tasks and serve download formats per rom - TaskSpec gains destructive and single_instance. The Tasks list asks for a typed confirmation before a destructive task, and POST /tasks/run answers 409 while a single-instance task is queued or running. - convert_library is both, and only runnable with ROM_CONVERTO_ENABLED. - The heartbeat reports CONVERTO.ENABLED, which hides Conversion settings from the sidebar and user menu and warns on the page. - DetailedRomSchema.download_formats lists what the caller can convert the rom's single file to, resolved by the backend's own operation table and empty for visitors who can't start a conversion. It replaces CONVERTO_DOWNLOAD_FORMATS in /api/config and the frontend's copy of the extension matching. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Yukine <devyukine@gmx.de> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: DevYukine <20647088+DevYukine@users.noreply.github.com> |
||
|
|
9255b44017 |
fix(converto): refuse cue sheets that reach outside their folder (#5008)
* fix(converto): refuse cue sheets that reach outside their folder rom-converto joins each cue FILE name onto the cue's folder without rejecting `..` or absolute paths, so a crafted cue made `chd compress` and `cue to-iso` pack any file the backend can read into the output. The library task already refused such cues; the on-demand download path did not. The check now lives in RomConvertoService.convert and mirrors how the CLI reads FILE lines (first to last quote). Also run the CLI from an empty private dir with an empty --config and --no-cache, so it no longer picks up .env, rom-converto.toml or its hash cache from the backend's cwd or home. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): remove a sandbox made after its run was cancelled Addresses Greptile review on #5008: a run cancelled while the sandbox thread was still creating the dir never reached the cleanup, leaving the dir behind. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
3b4e230b7c | Upgrade SQLAlchemy to 2.1 (#5007) | ||
|
|
640a783f3f |
feat(converto): convert the library in place and serve downloads in a requested format (#4999)
* feat(converto): integrate rom-converto for title id extraction and download conversion * fix(docker): ship rom-converto in the production image Only the dev Dockerfile installed the binary, so the integration could never enable on a released image. Fetch the same pinned, checksummed musl build in a dedicated stage and copy it next to RAHasher. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): skip the update check and batch info calls The CLI asks api.github.com for a newer release on every run unless told not to, so pass --no-update-check on each invocation. Inspect a rom's files in one `info --paths-file` run instead of one subprocess per file, and read the inspectable extensions from the capabilities manifest so scans skip files info cannot recognize. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(scan): keep sigil authoritative for title ids rom-converto ran first and overrode the ids sigil read. Sigil now runs first and records its per-file ids; rom-converto only fills files sigil left unset, on new or changed files, in one batch. Restore the base-id selection for sigil extractions on every platform, as on master. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(downloads): make conversion opt-in and bound the cache The download endpoint returned a converted file to every client once a platform had a target, including the browser player and apps that check hashes against RomFile. Conversion now needs ?converted=true. A pre-warmed copy is served whatever its size; the in-request size cap only gates starting a conversion. ROM_CONVERTO_CACHE_MAX_SIZE_GB (default 20, 0 unbounded) caps the cache: conversions and the pre-warm task stop when it is full, and cleanup evicts the least recently served copies. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(types): regenerate frontend types for the converto schema Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): address code-review findings (pr-ready step 2) - Fall back to rom-converto's stored ids only when it ran this pass, in disc order, so a rescan that skipped extraction keeps sigil's save target - Persist per-file title ids that extraction writes onto reused rows - Only authenticated callers may start an in-request conversion; past a 240s deadline serve the original and let the conversion finish into the cache instead of nginx returning 504 - Treat a probe OSError or timeout as a failed probe; kill the subprocess when the caller is cancelled - Give the pre-warm task the scan timeout and report progress in the ConversionStats shape the task UI reads - Reuse zip_cache constants, walk the cache off the event loop, tolerate files vanishing mid-cleanup, and trim long comments Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): simplify conversion code (pr-ready step 3) - Move the converted-download policy (target lookup, cached-first, sync size cap, deadline) from the endpoint into utils/conversion_cache and share conversion_target with the pre-warm task - Share one path lookup between get_cached_converted and get_or_convert; the pre-warm walks the cache once and tracks a running byte budget instead of walking it twice per rom - One normalize_platform_formats beside TARGETS_BY_PLATFORM for the config loader (via _validated_platform_map) and the settings endpoint; update_converto_settings takes a ConvertoConfig and is written back with dataclasses.asdict - read_infos owns its never-raise contract, so the scan drops its blanket except; drop the unused RomConvertoInfo.kind and error attributes - Sort files for the rom-converto identity only when it is used; stat each cached file once during cleanup Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(converto): trim comments (pr-ready step 4) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): convert on first download instead of pre-warming A library pre-warm fought the TTL: cleanup dropped every copy nobody downloaded within a day. Remove the Convert library task and convert on demand only. Files over ROM_CONVERTO_MAX_SYNC_SIZE_MB now start their conversion in the background while the original is served, so the next download within the TTL gets the converted copy at any size. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): drop decrypt and encrypt download targets Downloads now only change a rom's container or compression (CHD, RVZ, CSO, NSZ, ...); serving decrypted files is left for a separate decision. NDS and PS3 have no remaining targets. Also note that the conversion concurrency limit applies per process. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): move the cache limits into converto.* cache_max_size_gb and max_sync_size_mb join cache_ttl_hours in config.yml and PUT /api/config/converto_settings, replacing the ROM_CONVERTO_CACHE_MAX_SIZE_GB and ROM_CONVERTO_MAX_SYNC_SIZE_MB env vars, so every eviction knob is edited in one place at runtime. The loader takes its defaults from ConvertoConfig and one table holds each integer's minimum for both the loader and the payload. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): lock conversions with flock instead of a sentinel A conversion now holds a non-blocking flock on its key dir, which the kernel releases if the worker dies. That replaces the .partial sentinel, its 6-hour staleness guess (which a long ROM_CONVERTO_TIMEOUT could outlive), and the rename-aside takeover. Cleanup skips locked dirs, and partial output gets a hidden name so it never counts as a served copy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(converto): parametrize repeated test cases Collapse the per-platform info parsing, operation resolution and converto_active cases into parametrized tests, so a new platform or target is one row. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(scan): run rom-converto first with sigil as the fallback rom-converto reads each rom's new or changed files first, in one batch, and its title ids win. sigil still reads what it can, since it alone provides save targets and Switch content types, and fills the ids rom-converto left unset. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(converto): store per-file metadata read by rom-converto during scans * fix(scan): keep the stored save target when sigil reads nothing * fix(converto): read Xbox 360 disc ids and Wii title versions, store content type as text * feat(converto): save file icons, banners and backgrounds read by rom-converto * chore(converto): bump rom-converto to v0.23.0 * fix(converto): address review findings in the conversion cache, scan metadata and settings * refactor(converto): move per-file metadata out of the conversion PR Scan-time metadata (title ids, the 17 rom_files columns, artwork and converto.scan_metadata) moves to its own PR so its columns land with the UI that reads them. This PR keeps conversion only. The conversion cache no longer has uncompressed_size_bytes to budget with, so a conversion to an uncompressed target reserves a fixed multiple of its input and the cleanup pass after it evicts any overshoot. Co-Authored-By: DevYukine <20647088+DevYukine@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BuuZVVtVPNLRaCjTN9bgQ * feat(converto): let the client pick the download format with ?format= `?format=zso,iso` lists the formats a client can read. The stored file is served whenever its format is listed, even with conversion off, so most emulator clients never trigger a conversion. Otherwise the first listed format with a cached copy is served, then the first one rom-converto can produce. A conversion that outlasts a short wait answers 202 with Retry-After instead of falling back to the original, so a URL never serves two different files and a client never gets bytes it can't read. 406 means no listed format can be served. HEAD reports the same without starting a conversion. This replaces `?converted=true`, the per-platform download target and `max_sync_size_mb`; `cache_ttl_hours` stays config.yml-only. Co-Authored-By: DevYukine <20647088+DevYukine@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BuuZVVtVPNLRaCjTN9bgQ * feat(converto): convert the library in place with a manual task `converto.platform_formats` now names the format a platform's library is stored in, and the new "Convert library" task brings every matched rom to it. Each output is staged in a `.romm_tmp_` directory beside the original, moved into place, and only then are the originals (and a cue's tracks) deleted. Single-file roms take the new name, folder roms keep theirs and get their .m3u entries rewritten, and the file rows refresh, so a rom keeps its id, saves and collections. Only lossless conversions qualify, so xbox (xiso trims the dump) has no library format. Unmatched roms are skipped because a converted file no longer hash-matches a DAT. `/api/config` now carries the library targets and, per input extension, the formats a download can be converted to. Co-Authored-By: DevYukine <20647088+DevYukine@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BuuZVVtVPNLRaCjTN9bgQ * fix(converto): address Greptile and Copilot review findings - Publish a converted library file with a no-replace link, so a file that appears during conversion is never overwritten. - Delete originals only after the rom row or its playlists point at the new file, and keep them if that update fails. Playlists are rewritten atomically. - Refuse a cue conversion whose tracks another rom or another cue holds. - Remove stage dirs a killed conversion left behind. - Try later ?format= targets when a conversion fails, treat any locked key dir as converting, and cap how many conversions downloads can start. - Drop the unsupported iso target for CD platforms from the example config and list the ROM_CONVERTO_* variables in env.template. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(converto): address code-review findings (pr-ready step 2) Serve converted outputs at 0644, read cue sheets and playlists with a BOM, stage folder rom conversions outside the rom folder, keep one rom's failure from stopping the convert library task, accept alias extensions as the stored format, probe running conversions with a shared lock, and bound the timeout. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): simplify conversion code (pr-ready step 3) Check and chmod rom-converto output once in the adapter, canonicalize requested format aliases, reuse LINK_FALLBACK_ERRNOS and the handler's atomic write, make the download format table a constant, skip the probe lock once cached, and fold duplicated name checks and cache stat passes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(converto): trim comments (pr-ready step 4) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(converto): find rom-converto on PATH instead of ROM_CONVERTO_PATH Both images install the binary on PATH, the variable was undocumented, and RAHasher is already resolved the same way. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Yukine <devyukine@gmx.de> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: DevYukine <20647088+DevYukine@users.noreply.github.com> |
||
|
|
2d58122d29 |
feat(search): Rank exact title matches first in relevance-ordered searches (#4996)
* Rank exact title matches first in relevance-ordered searches Relevance only scored whether a ROM's name, filename or aliases held the search as a phrase, so a spin-off whose alias contains "Final Fantasy 7" tied with the game whose alias is exactly that, and the tie fell to title order. Searches ordered by relevance now rank an exact name or alias match first, then names starting with the search, then the phrase score. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * pr-ready step 2 (code-review): match escaped aliases and tidy search parsing The alias pre-check now looks for the term as the joined aliases store it, with JSON escapes, so a quoted alias (and, on MariaDB, a non-ASCII one) can rank as exact. Search phrases reuse the shared term split, the order_by API description matches the current ranking, and the dialect test's NULL row is a real SQL NULL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * pr-ready step 3 (simplify): flatten the search rank and share helpers The exact-name check is one IN over the folded terms, the provider alias check has its own helper, json_titles_contain_folded folds the title itself and builds on json_array_contains_value, PostgreSQL only scans the aliases for the raw form of a term, and the running-engine dialect tests share one scratch-table helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Rank one-word searches of three or more characters A search for an alias like "ff7" now puts the exact match first. The rule for when relevance leads (and the letter index is dropped) moves to search_relevance_leads, which the order clauses and the endpoint share: no explicit sort, and either a multi-word phrase or a term of at least three characters. Shorter terms keep the name order, since they match most of a library and ranking would sort every match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Rank exact titles stored with extra spaces or accented capitals The exact and prefix tiers now collapse runs of whitespace on the stored name and alias side too, so "Final Fantasy VII" ranks as exact for "final fantasy vii". On MariaDB, which stores non-ASCII characters as \uXXXX escapes that LOWER can't fold, a non-ASCII term is checked against the aliases decoded through JSON_TABLE, and the alias pre-check goes word by word, skipping words it can't match in escaped text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Rank search results against a stored, folded title column Search ranking compared the term against the name and each provider's alternative titles, which meant decoding JSON blobs per row and working around MariaDB's escaped Unicode, tabs and newlines. Store the folded name and aliases in a new `roms.search_titles` column instead, kept in sync by mapper events and `update_rom`, and backfilled by migration 0147 in batches. Ranking becomes two LIKE checks against that column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Keep fitting aliases after one that overflows the search titles cap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * Rank a name prefix only where the search ends a word "final fantasy viii" starts with "final fantasy vii", so Final Fantasy VIII took the prefix rank for that search. The name now has to continue with a non-alphanumeric character after the search, which a regex checks on the rows the LIKE prefix already narrowed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * pr-ready code review: fix punctuation prefixes and hidden sort direction - A search ending in punctuation has already ended its word, so the name prefix rank no longer needs a further non-alphanumeric character. - Relevance has no direction: a hidden descending order no longer reverses its ties, in the order clauses or the grouped aggregate. - An alias equal to the name isn't stored twice in `search_titles`. - `update_rom` reads the stored row once instead of up to three times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 * pr-ready simplify: keep relevance's direction rule with its order clauses - `_gallery_order_clauses` decides once whether relevance leads and drops the direction there, rather than each caller overriding it. - The search terms are built only where the rank needs them. - The page hydration query drops a sort its rows are reordered out of. - The ranking tests share one helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
25ee88e5dc |
Merge pull request #4997 from LoneAngelFayt/fix/upload-name-length-and-status-codes
fix(api): return 4xx for overlong names and duplicate collections |
||
|
|
2dfde1fee5 |
refactor: simplify pass (pr-ready step 3)
Route add_save's save and screenshot names through sanitize_asset_filename and keep the before-commit note on the helper instead of at each call site. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
374b626f2e |
fix: address code-review findings (pr-ready step 2)
Check screenshot names before the state or save is stored, move the update_rom fs_name check ahead of provider fetches, check the stamped state name on pull, skip the length check on a no-op rename, and share the sanitize-and-check block through sanitize_asset_filename. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
54e377ca9d |
Merge pull request #4982 from rommapp/claude/rq-slim-imports-7m0jrn
perf: keep task code out of the cron scheduler and idle RQ workers |
||
|
|
b8bb383ccd |
chore(uploads): apply review-polish pass
pr-ready step 4 (review-polish): trim comments that restate the code. |
||
|
|
0742f133e0 |
fix(api): apply code-review fixes for overlong names
pr-ready step 2 (code-review xhigh --fix): byte-check screenshot, rename and ROM fs_name paths, fit streaming save archive names, cap email and collection names, log duplicate collections at warning. |
||
|
|
d3c7be82e3 |
Merge pull request #4981 from rommapp/claude/rom-lazy-load-memory-7m0jrn
perf: trim idle memory of the backend processes |
||
|
|
a62996d2d2 |
fix(uploads): reject file names over the 255-byte filesystem limit
Upload names were held to FILE_NAME_MAX_LENGTH, 450 characters, but ext4, XFS, Btrfs and ZFS cap a name at 255 bytes. A longer name passed validation and the write failed with ENAMETOOLONG, a 500. Non-ASCII names hit it early: a Japanese title reaches 255 bytes at about 85 characters. Check the encoded length in the shared write path and in the save and state uploads, so those return 400. Saves are checked after the slot's datetime tag is added, since the tag adds 22 bytes. Memory card version files trim the card name to fit, because a 255-character card name leaves no room for the timestamp. |
||
|
|
a31136cd21 | Keep the FULLTEXT index on searches with short words or stopwords (#4970) | ||
|
|
103c59e9c0 |
fix: keep a consumer on the streaming queue when streaming is off
config.yml is re-read on every request, so streaming can be turned on without a restart, and exit save pulls queued before it was turned off still need a worker. With streaming off at boot, the general RQ worker now listens on the streaming queue too instead of leaving it without a consumer; the dedicated streaming worker still starts only when streaming is on. The check reads the exit status inline rather than through a function in an `if !`, which shellcheck flags (SC2310) since it disables errexit. Adds a fresh-interpreter test that init_sentry() never imports the SDK without a DSN, and drops a comment that restated the PR's rationale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gh1SRMfuK7BZmf6YxMqSyT |
||
|
|
dd3b0a6f99 |
perf: stop loading the auth and web stack in background processes
Importing any handler.auth submodule ran the package __init__, which built the auth handlers and so loaded authlib, joserfc and Socket.IO. models.user imports handler.auth.constants, so every process that touched the models paid for the whole auth stack. The handler instances now live next to their classes in handler.auth.base_handler. utils.context imported fastapi only for annotations; that import now sits under TYPE_CHECKING. An idle RQ worker drops from about 118 MB to 89 MB RSS. Each job's forked work horse now imports a little more on its own, about 0.2s on an x86 host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gh1SRMfuK7BZmf6YxMqSyT |
||
|
|
fb553b3409 | refactor(db): escape LIKE searches with SQLAlchemy's autoescape (#4976) | ||
|
|
78379718c7 |
perf: trim idle memory of the backend processes
Skip sentry_sdk.init when no SENTRY_DSN is set. Without a DSN the SDK reports nothing, yet init still loads every default integration (httpx, rich, jinja2, mako, pygments...), about 10 MB per process. Import alembic.config only in main.py's __main__ block, the one place that uses it, instead of in every gunicorn worker (about 8 MB). Don't start the RQ streaming worker when config.yml leaves streaming off (the default). It only runs streaming teardowns and exit save pulls, and costs about 115 MB idle. Measured on a gunicorn worker importing main: 213 MB -> 193 MB RSS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gh1SRMfuK7BZmf6YxMqSyT |
||
|
|
6941de13db | Remove unused code and deduplicate copied helpers (#4975) |