Commit Graph

383 Commits

Author SHA1 Message Date
Georges-Antoine Assi
2469839b66 fix(jsdos): play a .jsdos bundle that sits inside a game folder (#5672)
* fix(jsdos): play a .jsdos bundle that sits inside a game folder

The play check read the ROM's own extension, which is empty for a folder,
so a bundle moved into a folder (for example beside its manual) lost its
Play button. The backend now exposes has_jsdos_bundle, true when the ROM
is a bundle or has one at its folder's top level, and the js-dos player
asks the content endpoint for that file instead of a zip of the folder.

Fixes #5615

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(jsdos): assert the player downloads only the bundle file

Addresses Greptile's review on #5672: covers the bundle file id in the player URL and drops a comment that restated the constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pr-ready: code-review

Pin has_jsdos_bundle's value for a plain single file and for a bundle
missing from disk, on both the SQL and the with_files path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011waFLKWoBw9KCu31UJJ7Te

* pr-ready: code-review

Expose missing_from_fs on RomFileSchema so the js-dos player skips a
bundle gone from disk, the same rule has_jsdos_bundle applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011waFLKWoBw9KCu31UJJ7Te

* pr-ready: simplify

Share the top-level file predicate and the present-file exists subquery
between is_easyrpg_game and has_jsdos_bundle, compute the top-level files
once in apply_file_stats, and fold the two marker flag tests into one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011waFLKWoBw9KCu31UJJ7Te

* pr-ready: review-polish

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011waFLKWoBw9KCu31UJJ7Te

* pr-ready: prose

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011waFLKWoBw9KCu31UJJ7Te

* refactor(jsdos): rename isJsDosBundle to hasJsDosBundle

It also matches a folder that holds a bundle, so the name now says what
the backend flag it reads says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011waFLKWoBw9KCu31UJJ7Te

* fix(scan): derive a scanned rom's file flags from the files it read

A scan emits scan:scanning_rom before it writes the rom's file rows, so a
new rom reached clients with every file flag false (has_simple_single_file,
has_multiple_files, has_jsdos_bundle and the rest) until a reload. The
emits now derive those flags from the files the scan just read whenever it
rebuilt them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011waFLKWoBw9KCu31UJJ7Te

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 19:28:36 -05:00
Henrique Reis Neves
17d184f4b6 fix(config): warn about platform bindings to unknown slugs (#5580)
* feat(config): warn about platform bindings to unknown slugs

A config.yml binding whose value is neither a platform slug nor a
folder alias (a typo such as `snes-test: snse`) silently made a custom
platform with no metadata. Nothing pointed at the binding: the scan only
logged "Platform snse not identified", like any unknown folder.

Startup and the platform scan now log a warning that names the
system.platforms or system.versions key, the bound value and the
closest known slugs. Unbound folders are not checked, so custom
platforms stay quiet.

Closes #5464

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(config): treat IGDB version slugs as known bindings (pr-ready: code-review)

Bindings to IGDB platform-version slugs such as amiga-a-1200 are
identified by the scan, so they no longer warn. Startup reuses the
config that migrate_retired_filesystem_keys just loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(config): share the binding lookup with resolve_platform_slug (pr-ready: simplify)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(config): tighten binding warning docstrings and test typing (pr-ready: review-polish)

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>
2026-11-14 07:57:35 -05:00
Tyler Vigario
d96ec82e05 fix(scan): name a game by metadata priority, whatever order the scans ran in (#5546)
* fix(scan): name a game by metadata priority, whatever order the scans ran in

An unmatched scan asks only the sources a ROM has no match from yet, and
merges just their answers. A stored name that looks like a placeholder was
replaced by whatever name that subset gave, and a provider's name often looks
like one: LaunchBox calls Super C (USA).nes "Super C". So an unmatched
HowLongToBeat scan renamed it "Super Lucky's Tale", though LaunchBox ranks
above HowLongToBeat in scan.priority.metadata, and once a name no longer
looked like a placeholder no refresh could correct it.

Every source now keeps the title it gave in its own blob, as hash sources
keep their dump tags. On an unmatched, update or hashes scan the name goes to
the highest-ranked source among this scan's answers and the stored titles of
the sources the ROM is still matched to. A source matched before titles were
kept outranks the rest unknown, so the stored name stays. A stored name equal
to some source's title counts as derived, so a better-ranked source can
replace it; any other name is the user's and stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TsLtVzsT8WBDnc6ZSRyp2u

* fix(scan): count only a string as a source's kept title

The raw metadata editor stores any JSON, so a blob's name can be a list or an
object, which broke a refresh with an unhashable set element. kept_title now
reads a stored title for both settle_name and keep_base_fields, and anything
but a string counts as no title. settle_name's docstring is one sentence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TsLtVzsT8WBDnc6ZSRyp2u

* fix(scan): settle names across Hasheous-filled IGDB columns and pre-existing rows

code-review (xhigh) pass: stamp every blob a source fills, treat only ids the
row already held as stored matches, count this scan's titles as derived, and
drop non-string kept titles from responses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(scan): share one priority ordering for the name settle

simplify pass: order_merge_sources returns the full ordering so settle_name
skips its own config read, kept_title moves next to NAME_CLAIM_KEY and backs
the response filter, keep_base_fields' comments fold into one, and the name
priority tests share constants and parametrize their near-duplicates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(scan): reword settle_name's unknown-title comment

review-polish pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(scan): settle slug and artwork by priority too, under a scan_claims key

Each source's blob now keeps the name, slug, cover and screenshots it gave
under one namespaced scan_claims key (a ScanClaims TypedDict) instead of a
bare name key that shared the providers' own key space. settle_claims ranks
every claimed field by its own priority list, so a partial scan no longer
writes a lower-ranked source's cover over a better-ranked one. A matched
source with no claims on record holds the stored value only when that value
is set. The artwork orderings are computed once and shared with
apply_artwork_priority, so no config read is added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(scan): hide scan_claims from the API

The claims stay in each source's blob, but the provider metadata types no
longer declare them, so they're out of the OpenAPI schema and the generated
frontend types. Responses strip the key, and a raw metadata edit keeps the
stored claims while the source's match stands instead of taking the client's.

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>
2026-11-11 07:30:20 -05:00
Georges-Antoine Assi
fa3654dd79 fix(platforms): stop filing sgb folders as Game Boy Color (#5530)
* fix(platforms): stop filing sgb folders as Game Boy Color

ES-DE and Batocera name their Super Game Boy system sgb (Game Boy games
on the SNES adapter). Mapping sgb and sgb-msu1 to gbc gave those folders
Game Boy Color provider ids and limited IGDB searches to the wrong
platform. RomM has no Super Game Boy slug and IGDB, TheGamesDB,
RetroAchievements and LaunchBox list none, so leave the folders
unidentified; a config binding can still map them.

Fixes #5506

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(scan): keep a missing platform folder unless its alias exists

Addresses Greptile review on #5530: with the sgb aliases gone,
gbc2players became the reverse folder for gbc, and a rescan with the gbc
folder missing saved that nonexistent folder on the platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:10:44 -05:00
Sam Dornan
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.
2026-11-01 19:23:51 -06:00
Georges-Antoine Assi
b35eb4d07c fix(scan): clean up unreferenced rescan media, split scan_rom and move its parts into handler/scan (#5408)
* fix(scan): delete screenshots and media a rescan leaves unreferenced

A complete rescan keeps the stored artwork, so two kinds of file stayed on
disk with nothing pointing at them:

- screenshots indexed past a shorter new list, since files are named by
  position and only the indexes in range were rewritten
- media of a type removed from the preferences, since providers record no
  path for it and stale media was compared over the preferred types only

get_rom_screenshots now deletes the indexes past the new list, and
remove_stale_media compares every media type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(scan): split scan_rom's merge into named steps

scan_rom held seeding the row, following Demozoo links, splicing scene
summaries, resetting rematched sources, the scene lock, rehash cleanup,
priority merges for fields, tags and artwork, and the SteamGridDB pass in one
body. Each step is now its own helper, the SteamGridDB lookup a _RomLookups
method, and the providers' answers a dict keyed by source instead of fourteen
locals. The Pouet and CSDb link follows share one helper. Behaviour is
unchanged.

McCabe complexity of scan_rom goes from 68 to 13, and the function from 664
to 215 lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(scan): trim remove_stale_media's docstring per Greptile review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(scan): move the scan vocabulary, lookups and merge into handler/scan

scan_handler.py held the scan types and metadata sources, the per-source
lookups, the merge of their answers and the orchestration in one 2,000-line
module. It now builds on a handler/scan package:

- sources.py: ScanType, MetadataSource, the tag constants, RESCAN_RULES,
  should_consult, stored_match_id and the priority ordering
- lookups.py: RomLookups, the LaunchBox and Steam resolvers and
  get_main_platform_igdb_id
- merge.py: the pure steps that merge the sources' answers into a rom's
  columns

scan_handler.py keeps scan_platform, scan_rom, the asset scans and the media
downloads. Importers point at the module that now defines each name, and the
helpers that crossed a module boundary lost their leading underscore.
clear_rehash_misses takes the attempted sources instead of the lookups, so
merge does not depend on lookups. Behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(ci): import ScanType from handler.scan.sources in the e2e seed script

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(scan): harden leftover screenshot cleanup (pr-ready: code-review)

List the screenshots folder once, use isdecimal() for the index test, and
log rather than raise when a leftover can't be removed. Point three
comments at handler/scan instead of scan_handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(scan): tidy the merge helpers and patch paths (pr-ready: simplify)

- fetch_sgdb_rom refetches by stored_id and builds the SGDB name list
  itself, so the name sources stay private to lookups.
- follow_demozoo_link checks the source is enabled; scan_rom loops over
  Pouët and CSDb.
- order_merge_sources holds the one ordering pass, and
  build_metadata_handlers adds the empty SGDB entry.
- Leftover screenshots go through the quiet-delete helper, renamed
  _discard_file.
- Tests patch rom lookups through handler.scan.lookups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(scan): never leave a recorded media or screenshot path without its file

- remove_stale_media only deletes a file whose owner or source changed
  when that new owner stores the type again in this pass. A file nothing
  records is still deleted.
- Screenshots past a shorter list are pruned by remove_screenshots_past
  once the new paths are saved, in both download_rom_resources and
  update_rom, so a failed cover or manual leaves them in place.
- The release-notes schema diff watches scan_handler.py beside
  scan/sources.py, for ranges that span the move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:23:13 -04:00
Georges-Antoine Assi
63faff8883 fix(misc): Rename paths, rescan artwork, scan lookups and streaming teardown fixes (#5396)
* fix(roms): rewrite only the moved part of a renamed rom's file paths

Renaming a rom rewrote each of its files with
`str.replace(old fs_name, new fs_name)` on both the name and the path. On
disk, rename_fs_rom moves only `fs_path/old` to `fs_path/new`, so:

- a folder rom's inner file named after the folder (`Game (Disc 1).bin`
  in `Game/`) was renamed in the database but not on disk;
- an fs_name that also appears in the platform path (a rom named `n64`
  under `n64/roms`) rewrote the platform path too.

_moved_file_location mirrors the move instead: a single-file rom's name
changes, a folder rom's files keep their names under the renamed folder,
and anything else is left alone.

_refetch_changed_matches now returns the ids it refetched, so the
RetroAchievements badge download keys off that rather than repeating the
comparison, and the shared-media rematch uses the same _match_changed
check as the refetch loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(scan): keep artwork a complete rescan has nothing to replace with

A complete rescan deleted the rom's cover, manual, screenshots and every
provider media folder before asking any provider, then reset the stored
paths. A provider that was down, rate limited or no longer had the art
left the rom with none.

The wipe is gone, and scan_rom no longer resets the path columns on a
complete rescan. The download step already replaces what changed:
covers, manuals and screenshots refetch when their URL differs, and
remove_stale_media drops provider media whose owner or URL changed. The
URLs and locks are still cleared, so whatever answers now can replace a
file; a file nothing replaces stays where it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(scan): move scan_rom's provider lookups onto a _RomLookups class

scan_rom defined 16 provider lookups as closures over its own locals
(scan type, platform, rom, rom_attrs, enabled sources, the attempted and
inconclusive sets), so none of them could be read or tested apart from
the 1,000-line function around them.

They are now methods of _RomLookups, a dataclass holding exactly what
they used to capture, along with the helpers they share (consults,
note_inconclusive, resolve_fetch and the cached match files). scan_rom
builds one instance and keeps its local names for the shared sets, so its
body is unchanged apart from the calls. SteamGridDB's lookup stays nested
because it reads the other providers' results.

scan_rom drops from 977 to 664 lines. Its own complexity is unchanged:
that comes from the merge after the lookups, not the lookups themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(streaming): one teardown order for every way a session ends

A session could be torn down three ways, each spelling out its steps:

- teardown_released_session (owner release and single admin release)
- teardown_abandoned_session (stale takeover and the reaper)
- force_release_all's inline _teardown

The first two ran the same stop/playtime/activity/state/saves sequence
in two copies. The sweep differed in ways that mattered: it held no drain
marker while it worked, recorded the termination after the stop (so a
polling tab could miss it), marked the exit save pull pending only after
the stop, and deleted the key unconditionally, even if a newer claim had
replaced the one it read.

_stop_and_collect now holds the shared sequence, and both lifecycle
teardowns call it after their own opening (a drain marker for a release,
a staleness-checked marker for an abandoned session). The sweep runs
teardown_released_session for each session, like a single admin release.
With no container config left, it still records the termination, then
frees the key through the guarded release_own_session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: apply code-review findings (pr-ready step 2)

Record playtime and clear the activity entry when force-release-all frees
a session whose container config is gone, and let the PICO-8 cartridge
fallback see a cover a complete rescan keeps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: apply simplify findings (pr-ready step 3)

Let _RomLookups.attempts() record the attempt it gates, drop scan_rom's
local aliases for the lookups' state, read the platform slug off the
lookups in fetch_launchbox_rom, seed the kept artwork paths into
rom_attrs for every rescan so the PICO-8 fallback reads them directly,
return None from _moved_file_location when a file did not move, and
share the playtime and activity steps through close_session_record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: address Greptile review on #5396

Drop a cover's other formats once a new one is stored, so a kept upload
in another extension can't shadow it, and move the rename path rule onto
FSRomsHandler next to rename_fs_rom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 11:06:52 -04:00
Georges-Antoine Assi
2d140e606a fix(scan): consult sources from one rule table and keep stored matches on refresh (#5394)
* refactor(scan): decide which sources a scan consults from one rule table

Each of scan_rom's 16 provider fetchers opened with its own copy of the
same gate: is the source enabled, does it cover the platform, and does
this scan type (new, complete, update, unmatched, hashes) ask it about
this rom. The copies differed in small ways (which platform field,
whether a hash scan counts, whether an id alone counts as matched) that
were only visible by reading all 16 side by side.

RESCAN_RULES now holds one RescanRule per source, and should_consult
applies them. Each fetcher's gate is a single consults() call. The
fetchers' lookup logic is unchanged.

A brute-force comparison of the old inline gates against should_consult,
over 57,600 combinations of scan type, new rom, enabled source, id,
metadata, platform id and platform slug, found no differences. The new
test_scan_rescan_rules.py pins the rules per source without a database.

The nested fetchers drop from a combined cyclomatic complexity of 215 to
87 (437 to 264 lines).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(scan): pin rescan rule columns independently, cover Hasheous' platform id

Addresses Greptile's review: an explicit table of each rule's id and
metadata columns, Hasheous in the platform-id test, and a one-sentence
should_consult docstring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(scan): keep stored matches on refresh and pick rescans from the rule table

- Every fetcher refetches a stored id through stored_match_id(): an update,
  or an unmatched retry of missing metadata, keeps the id instead of trading
  it for a hash or filename match. IGDB now prefers it over Hasheous and
  Playmatch, MobyGames and ScreenScraper refetch it on an unmatched retry, and
  Demozoo refetches it at all.
- Playmatch runs only when a source that reads its ids will be consulted.
- should_scan_rom picks update and unmatched roms with should_consult, so the
  platform gates and the metadata check apply, and Playmatch alone picks nothing.
- unmatched_supported takes the platform instead of reading rom.platform.
- scan_rom's handler table and update_rom's refetch table take their columns
  from RESCAN_RULES; a test checks METADATA_SOURCE_COLUMNS agrees with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 15:03:01 -04:00
cfranz-medsoto
332643b5d2 Fix scan failure when ROM name is missing (#5377)
### Summary

Prevent ROM scanning from failing when the `name` field is missing from `rom_attrs`.

The identification log message now falls back to `fs_name` when `name` is unavailable. This avoids a `KeyError` during scanning while preserving the existing log output for ROMs that have a name.

### Motivation

During a library scan, RomM raised a `KeyError: 'name'` in `scan_rom()` when attempting to log a successfully identified ROM. This caused the affected ROM's scan to fail.

Using `fs_name` as a fallback allows the scan to continue even when the metadata name is missing.

### Testing

- Reproduced the issue during a ROM library scan.
- Verified that scanning completed successfully after applying the fallback.

### AI assistance

AI assistance was used to help investigate the error. The fix was tested locally against the affected RomM installation.
2026-10-29 12:09:51 -04:00
Spinnich
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>
2026-10-28 19:53:06 -04:00
Nathan Krebs
d8f08a60f2 fix(scan): fall back to filename name when only libretro matches (#5241)
* fix(scan): fall back to filename name when only libretro matches

Libretro matches by filename and supplies no name. On a complete scan or a
newly added ROM that only libretro identifies, rom_attrs had no name, so the
identified-as log raised KeyError and the scan result was discarded.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(scan): keep a new rom's own name when libretro alone matches

code-review (xhigh) pass. A physical game is created with the name the
user typed, and the filename fallback would rebuild it from the
sanitized fs_name ("Kingdom Hearts HD 2.5" -> "Kingdom Hearts HD 2").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(scan): simplify the new-rom name fallback expression

simplify pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(scan): clarify the name fallback comment

humanizer pass.

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>
2026-10-28 09:40:40 -04:00
danielcopper
e304e08a88 perf(roms): let a list fetch leave the provider metadata off each item (#5228)
* perf(roms): let a list fetch leave the provider metadata off each item

GET /api/roms takes with_provider_metadata, default true. When it is
false, every *_metadata field but manual_metadata (the twelve provider
blobs and merged_ra_metadata) comes back null. The fields stay in the
schema, so the response shape is unchanged. metadatum and the flat
fields read from the blobs (alternative_names, youtube_video_id,
path_video) are serialized as before.

The fields are nulled on a copy of the finished schema rather than on
the Rom, because an assignment to the row inside the request's session
would be flushed to the database. The set of fields is derived from the
schema, and a test pins the names, so a new *_metadata field joins on
purpose.

Closes #5227

* refactor(roms): list the provider metadata columns in one place

PROVIDER_METADATA_COLUMNS on the model now backs the scan snapshot, the
unmatch reset and the list endpoint's opt-out, which each spelled out the
thirteen columns. The opt-out test is cut down to one request per mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(roms): spell out the RetroAchievements field in the opt-out

The response set is now the provider columns less ra_metadata, plus
merged_ra_metadata, which the schema serves with absolute badge paths.
The nulling reads as one conditional step before the return.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* perf(roms): copy only the achievement dicts in merged_ra_metadata

The deep copy cloned the whole RetroAchievements blob to rewrite two badge
paths per achievement. Building new achievement dicts keeps the stored
paths relative at a quarter of the cost: 24.2 ms to 6.3 ms over a 500-item
page of a real library, with identical output.

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>
2026-10-28 08:33:51 -04:00
Zach Clendenen
261178cb25 fix(streaming): share RetroArch stream saves and states with Cloud Sync (#5197)
A streamed RetroArch exit's save landed in "No slot", and the stream's
states were filed under a different emulator than the one Cloud Sync and
the other RetroArch clients use, so neither side could see the other's.

A streamed exit's save is now stored as an `autosave` version, like the
other clients' autosaves. Stream saves and states are filed under the
core's RetroArch folder, which the broker reports as `library_name`; a
broker that doesn't is filed under the core id. A stream resumes from any
state in the booted core's folder, including other clients' states and
ones filed under an alias of the folder, and the picker's core rule gains
the folder's names so it offers them too.

Cloud Sync shares the slot with stream captures but never writes over or
deletes one: an upload goes to the slot's newest non-capture state or
creates one, sending a capture's own bytes back is a no-op, and a delete
removes the slot's other states and leaves captures in place.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 15:50:39 -04:00
Zach Clendenen
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>
2026-10-07 20:44:14 -04:00
Sam Dornan
7b1028bedd feat: search platforms by slug, abbreviation and alternative names (#5107) 2026-10-04 22:59:52 -04:00
Sam Dornan
b23bc79b46 feat(launchbox): scrape box front, back, spine and 3D box art (#5129) 2026-10-04 16:25:41 -04:00
Zach Clendenen
6fb4e4ea1b perf(scan): skip the second write and reload for newly inserted roms (#5070)
* perf(scan): skip the second write and reload for newly inserted roms

A new rom is inserted and reloaded by the socket scan just before scan_rom, which then merged and reloaded it again before identification. Only existing roms take that write now. The insert carries the file hashes, size and title id so a scan that stops early still leaves a row rename detection can match.

* refactor(scan): address pr-ready code review

* chore(scan): pr-ready code-review pass

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor(scan): pr-ready simplify pass

Fold the new insert tests into TestIdentifyRomReassociation, rename
_added_rom to scanning_rom, and name the emit test after both checks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(scan): pr-ready review-polish pass

Assert the unset file columns one by one, since mypy rejects comparing
the int-typed fs_size_bytes against None in a tuple.

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>
2026-10-03 10:23:13 -04:00
Georges-Antoine Assi
3deb38d93a fix(scan): keep an uploaded manual when the rom had no scraped one (#5030)
* fix(scan): keep an uploaded manual when the rom had no scraped one

Update, unmatched and hashes scans pin a stored manual url, but a manual
uploaded to a rom without a scraped url has nothing to pin. The provider's
url then won, differed from the empty stored one, and its download
overwrote the upload at the shared manual path. A locked manual, or one
on disk with no source url, now keeps its empty url through the scan.

Fixes #4101

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(scan): drop a scraped manual's path on unmatch, test the download stage

Addresses Greptile's review on #5030:
- Unmatch cleared url_manual but kept path_manual, so the next scan read the
  old scraped manual as an upload and never fetched the new match's one. It
  now clears path_manual too, unless url_manual is locked (an upload).
- Trim the url_manual comment to two lines.
- Carry the scan result through download_rom_resources in the upload test and
  check the manual is never stored over.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 18:59:08 -04:00
Georges-Antoine Assi
746df798c0 fix(scan): refresh screenshots when only their order changes (#5029)
* fix(scan): refresh screenshots when only their order changes

Stored screenshots are named by position (0.jpg, 1.jpg, ...), but the
re-download check compared the provider's urls as an unordered set, so a
reorder was never picked up. Compare the lists directly, in both the scan
download step and update_rom.

Fixes #4103

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(scan): cover the screenshot reorder in update_rom

Address Greptile review on #5029: add an endpoint test for update_rom's
own reorder check, and narrow await_args before reading its kwargs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(scan): drop the old screenshot when its replacement fails

With overwrite on, a failed download left the previous image at that
index. The next scan saw matching urls and a file on disk, so it kept
the stale image for good. Remove it instead, so the next scan refetches.

Addresses Greptile review on #5029.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 18:58:37 -04:00
Claude
ef57ee300d fix(scan): count every metadata source when deciding a ROM is identified
The not-identified check in scan_rom listed 13 provider ids by hand and
missed tgdb_id and libretro_id, so a ROM matched only by Libretro (or by a
TGDB id from Hasheous) took the early return: it skipped the SteamGridDB
lookup and missing_from_fs reset, while Rom.is_identified counted it as
matched. Derive the check from METADATA_SOURCE_COLUMNS instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XZW9ChvmiTKXYYWY6JvTKU
2026-10-01 04:12:16 +00:00
Sam Dornan
6941de13db Remove unused code and deduplicate copied helpers (#4975) 2026-09-30 18:51:36 -04:00
Sam Dornan
7a8e9f32f0 Match RetroAchievements by RA hash only, never by Hasheous' game ID (#4962)
* Match RetroAchievements by RA hash only, never by Hasheous' game ID

Hasheous links an RA game to a whole Hasheous game record, so every dump
grouped under it (other revisions, regions, bad dumps) got that RA ID and
its achievements, even when RA doesn't list the dump's hash as compatible.
It also bypassed RomM's own RA hash lookup and reached the priority merge
when RA was deselected or ranked below Hasheous.

Stop reading the RetroAchievements ID from the Hasheous lookup, drop the
unused RA proxy fetch (its response was discarded), and have fetch_ra_rom
always go through RA's hash list. Existing wrong matches clear on a
Complete rescan.

Fixes #4959

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdE1MDoDitrZZgZ7PQ3s1Z

* pr-ready step 2 (code-review): cover stale and deselected-RA matches, fix stale copy

Parametrize the Banjo-Kazooie regression test over RA selected and
deselected, starting from a stale Hasheous ra_id, so it pins both the
Complete-rescan clear and the priority-merge leak. Move the RA comment
onto the hash-lookup branch, drop a merge get_igdb_game already does,
and stop the Hasheous provider description claiming it supplies
RetroAchievements IDs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdE1MDoDitrZZgZ7PQ3s1Z

* pr-ready step 3 (simplify): reuse scan stubs in the Hasheous RA test

Build the Banjo-Kazooie platform, ROM and top-level file with the shared
add_n64_platform/add_rom/_top_level_rom_file helpers, state the expected
RA lookup as a parameter instead of branching on it, and drop a comment
that described the removed Hasheous path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdE1MDoDitrZZgZ7PQ3s1Z

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 11:28:46 -05:00
Sam Dornan
b5070cd984 fix(backend): keep derived rom state in step with its source (#4931) 2026-09-30 11:49:11 -04:00
Sam Dornan
d344662eac Keep ScreenScraper disc art for every disc of a multi-disc game (#4885)
* Keep ScreenScraper disc art for every disc of a multi-disc game

ScreenScraper tags each disc's support-2D art with a "support" number,
but the extractor kept only the first support-2D it met, so discs 2 and
up were never downloaded or shown.

The first disc still fills physical_url/physical_path, which the cover
art, disc-spin animation and exporters read. Every later disc goes to a
new ss_metadata.physical_extra_discs list, is downloaded next to it as
physical/physical_disc<N>.png, and gets its own entry on the v2 Artwork
subtab.

Existing ROMs pick up the extra discs on their next metadata refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Type the extra-disc test metadata so mypy can index it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Label the first disc's art on multi-disc games

ss_metadata now records which disc physical_url shows, so the Artwork
subtab can label it "Physical media (disc N)" alongside the later discs.
It stays plain "Physical media" for single-disc games, gamelist art, or
when no later disc's art is on disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* pr-ready step 2 (code-review): harden disc numbers and rematch cleanup

- Read ScreenScraper's disc number with safe_int and clamp it to 1, so
  a zero, negative or non-string "support" value counts as the first disc.
- Remove the physical folder on an ss_id change when only later discs
  had art, so a rematch doesn't keep the old game's disc images.
- Collapse store_metadata_media's two result lists into one target list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* pr-ready step 3 (simplify): one home for the media a provider dict records

- Add FSResourcesHandler.recorded_media, which lists every recorded file
  including a <type>_extra_discs list, so store_metadata_media and the
  update_rom cleanup share one rule and neither special-cases physical.
- Skip stripping a disc's URL once a better region already supplied it.
- Share the ScreenScraper disc tests' patch setup in an _extract helper
  and spell out each test's discs instead of slicing a fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Refetch media whose source changed and keep shared art on rematch

- A scan now deletes each stored media file whose recorded URL changed,
  or a later disc's file the new metadata dropped, before storing, so a
  physical.png saved from another disc's art is fetched again instead of
  showing under a "(disc 1)" label.
- A rematch deletes a later disc's own file instead of the whole physical
  folder, so gamelist art sharing that folder survives.

Addresses the Greptile review on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Keep a shared media file a higher-priority provider still records

The stale-media check could delete a shared file such as physical.png
because a lower-priority provider's URL for it changed, even though the
file held a higher-priority provider's unchanged art. Each provider now
leaves alone the paths the providers before it still record.

Addresses the second Greptile review on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Decide stale shared media by which provider owns the path

The previous rule kept any path a higher-priority provider recorded, so
when ScreenScraper newly claimed a physical.png that still held older
gamelist art, neither provider refetched it. A shared path's file now
belongs to the first provider, in priority order, that records it, and
the file is refetched when that owner or its URL differs between the
previous and current metadata. Every provider is compared in one pass,
including ones outside this scan's sources.

Addresses the third Greptile review on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Name the fields of recorded media instead of using bare tuples

RecordedMedia was a four-item tuple alias that callers unpacked by
position, with a comment spelling out what each slot held. It is now a
NamedTuple with explicit fields and a path property, and the per-path
ownership claim in remove_stale_media gets the same treatment.

Addresses review feedback on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 13:59:07 -05:00
Claude
42e5b5d119 Remove the no-emdash Trunk linter after a one-time sweep
The linter ran over every Markdown file and Python comment, so full-repo
trunk runs on master kept failing on em-dashes that predate it. Replace
the existing ones once and drop the check. The AGENTS.md rule stays, the
v2 ESLint rule stays, and pr-ready's humanizer pass catches new ones in
prose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RyamrxVw5BzEidVzm68LY7
2026-09-28 16:59:56 +00:00
Sam Dornan
b4901551c8 fix(scan): stop rescans inflating live platform game counts (#4867) 2026-09-28 08:54:50 -04:00
Sam Dornan
146464551b perf(scan): download a rom's media files concurrently (#4842)
* perf(scan): download a rom's media files concurrently

download_rom_resources fetched the cover, manual, each screenshot, each
provider media type and every RetroAchievements badge one after another,
so a single ROM never used more than one of the ScreenScraper account's
request slots.

They now download together. ScreenScraper media still goes through its
existing thread and rate limiters, and badges share a new cap of 8 in
flight across all scans. The path columns and changed provider media
dicts are written back in one update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf

* style(tests): sort imports with the Trunk isort config

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf

* fix(scan): code-review fixes for concurrent media downloads

- Run provider media dicts one after another, since they share paths
- Await every download before raising the first failure (gather_all)
- Fetch each duplicate media or badge path once (store_ra_badges)
- Reuse store_ra_badges in update_rom
- Share the in-flight test helper and trim comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf

* refactor(scan): simplify pass on concurrent media downloads

- Move gather_all to utils/concurrency and unpack its results directly
- Let write_file_streamed create the badge directory instead of every badge
- Share the in-flight test helper through tests/concurrency_stubs
- Stub downloads with AsyncMock through one fixture, drop a redundant test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf

* fix(scan): save the paths that landed when a provider download fails

Cover, manual and screenshot paths are written before a provider media or
badge failure is re-raised, so a failure there no longer loses them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf

* fix(scan): save each download group's results independently

Paths, provider media and badges each keep their own outcome, and every
change that landed is written before the first failure is re-raised. The
test builds a real Rom instead of a namespace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 13:35:21 -05:00
Sam Dornan
5a6c895d33 chore(mypy): give every generic its type arguments (#4818)
* chore(mypy): switch to strict mode with listed exceptions

Replace the hand-picked flags with `strict = True`, turning off only the
four flags that aren't clean yet (disallow_any_generics,
warn_return_any, disallow_untyped_calls, disallow_untyped_decorators).
Any other strict flag, including those future mypy releases add to the
preset, is on by default.

That turns on no_implicit_reexport, strict_equality and extra_checks:
- Import each name from the module that defines it. About 240 test
  sites patched a dependency through the module that imported it
  (`scan_module.fs_rom_handler`); they now import the same object from
  its source, so every patch targets what it did before. Tests that
  replace a module attribute are unchanged.
- handler.streaming.memory_cards re-exports store_memory_card_version
  explicitly, since endpoints call it there and tests patch it there.
- mutagen gets implicit_reexport, as it re-exports without __all__.
- Test comparisons build typed values (CoverResult, a typed expected
  dict, enum .value) and the CORS lookup casts for its identity check.
- One ss_handler ** spread keeps a coded ignore: extra_checks wants its
  NotRequired dump_* keys spelled out, and the media dict never has them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G

* chore(mypy): give every generic its type arguments

Drop disallow_any_generics from the strict-mode exceptions and fix the
347 bare generics it reports, 230 of them in app code.

- Bare `dict` becomes `dict[str, Any]`: update payloads, raw provider
  JSON and endpoint bodies map string keys to mixed values, so the Any is
  real and now written down. The OpenAPI document is unchanged.
- Rom query filters take and return RomSelect; _music_facet_joins and
  _exclude_hidden are generic over the Select they're given, and
  _build_hash_selects returns id-only selects.
- Redis clients are typed by what they return: the decoding caches are
  Redis[str], the RQ connection and binary cache Redis[bytes].
- The rest get explicit parameters: Row, Pattern, ColumnElement,
  QueryableAttribute, SpooledTemporaryFile, Task, Future and friends.

Precise types reached callers that had been getting Any, which surfaced:
- The LaunchBox cache writer is fed binary-cache pipelines.
- The flashpoint and IGDB request helpers return raw JSON of varying
  shape, not always a dict.
- The rom search endpoint returned dicts under a list[SearchRomSchema]
  annotation; it now validates them into that schema.
- The audit filter's id subquery selects strings.
- In tests the binary cache is the non-decoding fake shared with
  async_cache, so it is cast to Redis[bytes] rather than changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G

* test(upload): assert cleanup against the patched upload directory

The 409 test checked config's ROM_UPLOAD_TMP_BASE while the fixture patches
the endpoint's copy to tmp_path/uploads, so it passed even if cleanup failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G

* chore(mypy): keep the row type through the ROM filter helpers

filter_roms and its helpers also receive select(Rom.id) membership queries,
so they now take and return the caller's Select type instead of narrowing to
RomSelect. merged_ra_metadata mixes scalar and list values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 16:32:29 -05:00
Sam Dornan
bd16648c9a chore(mypy): switch to strict mode with listed exceptions (#4817)
* chore(mypy): switch to strict mode with listed exceptions

Replace the hand-picked flags with `strict = True`, turning off only the
four flags that aren't clean yet (disallow_any_generics,
warn_return_any, disallow_untyped_calls, disallow_untyped_decorators).
Any other strict flag, including those future mypy releases add to the
preset, is on by default.

That turns on no_implicit_reexport, strict_equality and extra_checks:
- Import each name from the module that defines it. About 240 test
  sites patched a dependency through the module that imported it
  (`scan_module.fs_rom_handler`); they now import the same object from
  its source, so every patch targets what it did before. Tests that
  replace a module attribute are unchanged.
- handler.streaming.memory_cards re-exports store_memory_card_version
  explicitly, since endpoints call it there and tests patch it there.
- mutagen gets implicit_reexport, as it re-exports without __all__.
- Test comparisons build typed values (CoverResult, a typed expected
  dict, enum .value) and the CORS lookup casts for its identity check.
- One ss_handler ** spread keeps a coded ignore: extra_checks wants its
  NotRequired dump_* keys spelled out, and the media dict never has them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G

* test(upload): assert cleanup against the patched upload directory

The 409 test checked config's ROM_UPLOAD_TMP_BASE while the fixture patches
the endpoint's copy to tmp_path/uploads, so it passed even if cleanup failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 15:45:37 -05:00
Sam Dornan
cbfc904a48 fix(ra): count RomM's own RA hash match as RetroAchievements verification (#4816)
* fix(ra): count RomM's own RA hash match as RetroAchievements verification

The RetroAchievements verification chip, the header Verified badge and the
library verified filter only read Hasheous' `ra_match` flag. RetroAchievements
hashes only part of some ROMs (NDS, PSP), so Hasheous never flags those from
their file hashes, and a ROM RomM matched to its RA game by RA hash still
showed a grey chip.

The RA handler now records `hash_match` in `ra_metadata` whenever the ROM's
RA hash is one RetroAchievements lists for the matched game, whichever route
found the game (hash lookup, Hasheous-supplied id, filename tag, update scan
or a manual edit). The frontend verification helper and the backend verified
filter count it alongside Hasheous' flag. Existing ROMs pick it up on their
next scan.

Fixes #4801

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfQbq2ZUFK53NMXPNktdaM

* style: satisfy trunk isort and no-emdash-in-comment

Sort imports with the repo's .isort.cfg and replace the comment em-dashes
in MetadataTab.vue that trunk flags once the file is modified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfQbq2ZUFK53NMXPNktdaM

* fix(ra): address code-review findings on the RA hash match

- A HASHES rescan whose RA lookup ran and found nothing clears
  `hash_match`, mirroring the Hasheous guard; a lookup that errored keeps it.
- A manual RA id change that can't be resolved no longer keeps the previous
  game's `hash_match`.
- `_search_rom` no longer caches a failed hash-list download ({}) as an
  empty index for the whole refresh window.
- Update the `verified` filter description and trim the romVerification
  header comment.

Step: pr-ready code-review (xhigh --fix)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfQbq2ZUFK53NMXPNktdaM

* fix(ra): don't let a failed hash check block an RA ID lookup

`get_rom_by_id` now treats the hash-list check as secondary: on failure it
logs, keeps a match already recorded for the same game, and still returns
the game. A failed hash-list download raises "RetroAchievements
unavailable" instead of reading as "no match", so scans treat RA as
inconclusive and keep the stored flag.

Addresses the Copilot and Greptile review findings on ra_handler.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfQbq2ZUFK53NMXPNktdaM

* refactor(ra): simplify the RA hash-match verification

- Cache the parsed RA hash index per platform, keyed by the cache file's
  mtime, so a scan parses it once instead of once per ROM.
- Check the hash only after `get_rom_by_id` has resolved the game.
- Give each frontend verification database its own `matches(rom)`, which
  drops the `ra_match` special case in the shared helper along with
  `matchesDatabase` and `VERIFICATION_KEYS`.

Step: pr-ready simplify

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfQbq2ZUFK53NMXPNktdaM

* style(v2): polish romVerification naming and comment

Rename the Hasheous matcher factory to `anyHasheousFlag` and trim the
VERIFICATION_DATABASES comment to two lines.

Step: pr-ready review-polish

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfQbq2ZUFK53NMXPNktdaM

* fix(ra): keep a recorded hash match only for the same RA hash

When the hash-list check fails, `get_rom_by_id` now keeps a stored
`hash_match` only if both the game and the ROM's RA hash are unchanged, so
a rehashed ROM isn't left verified by a hash nobody checked. The
romVerification tests build on the shared typed `SimpleRom` fixture
instead of casting a bare object.

Addresses the Greptile review findings on ra_handler.py and
romVerification.test.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfQbq2ZUFK53NMXPNktdaM

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 15:33:55 -05:00
Sam Dornan
3750d6ff70 chore(mypy): require full annotations outside tests, type the setup responses (#4795) 2026-09-26 15:31:00 -04:00
Sam Dornan
63cd9eb1b8 fix(backend): replace the legacy Query API with Select and type the session decorators (#4730) 2026-09-25 21:19:02 -04:00
Georges-Antoine Assi
603e3b0c93 fix(sync): keep state screenshots separate per core
RetroArch names a slot's state the same under every core, and its
screenshot was filed per ROM, so two cores' `<rom>.state.png` shared
one file and one row. File them under a per-core screenshots folder,
upsert by path, and only match a state to a screenshot in its own core's
folder or the ROM-level one.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:02:00 -04:00
zurdi
56a9609303 fix(scan): read a kept blob only when it holds lists of strings
Addresses Greptile's review: an edit of a ROM's raw metadata stores
whatever JSON it is given, so a skipped source's stored blob can be a
list or a string, and a dump_* value a bare string. Reading it assumed an
object and would have crashed the ROM's scan or split a tag into
characters; anything else is now read as no tags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:25:56 +02:00
zurdi
9cf751df29 refactor(scan): simplify kept hash-source tags after review
- A kept tag only fills an empty region or language slot: the row's
  value may come from a source the scan didn't ask either (a gamelist),
  and a hash source's old answer mustn't replace it. Fresh answers still
  work as before.
- A rehash that drops the Hasheous match now does so before the tags are
  resolved, so the ROM doesn't take tags from the match it's losing.
- One reader for this scan's blob and the stored one, every tag field
  recorded (empty lists included), and one ordered list of claims instead
  of a dict plus a list.
- The applied sources and the hash sources are ordered in one pass, since
  each pass rereads config.yml, instead of adding a read per ROM.
- Tests: one fixture per lookup, the blob assertion folded into the
  translated-dump test, and new ones for the gamelist case and the
  dropped Hasheous match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:13:42 +02:00
zurdi
a961143de1 fix(scan): address the code review of kept hash-source tags
- A handler reporting a tag field as null records no tags instead of
  raising in the middle of the ROM's scan.
- One home each for the tag fields and the blob keys their dump tags are
  kept under, which the writer and the reader both use.
- Test a HASHES scan, which never asks ScreenScraper again and used to
  drop its dump tags every time, and a fresh answer without our dump
  replacing the tags the blob kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:07:06 +02:00
zurdi
59920403ae fix(scan): keep a hash source's tags when a scan skips it
The regions, languages and tags a hash-matched source (ScreenScraper,
Hasheous) gave a ROM were only known while that source answered. A scan
that didn't ask it, such as an UPDATE with only IGDB selected or an
UNMATCHED scan of a ROM Hasheous already matched, rebuilt the tags from
the filename and the sources it did ask, and dropped them: the row can't
say which of its tags came from where.

Each hash source now keeps the tags its dump gave in its own blob
(dump_regions, dump_languages, dump_tags), and a scan that doesn't hear
from a source the ROM still carries the id of reads them from there. A
complete rescan still clears the id and blob of a source it drops, so
those tags go with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:02:35 +02:00
Sam Dornan
b5e50a14cc feat(metadata): tag a dump from the flags ScreenScraper raises on it (#4666) 2026-09-23 07:14:46 -04:00
Sam Dornan
ddd87ff554 feat(metadata): take region and language from the dump a hash matched (#4664) 2026-09-22 23:47:23 -04:00
Sam Dornan
cf19c8ae35 fix(backend): clear the remaining mypy errors outside roms_handler (#4723) 2026-09-22 19:00:24 -04:00
Sam Dornan
4542998510 fix(backend): make type ignores honest and replace mypy trunk-ignores with fixes (#4711)
* fix(backend): make type ignores match what mypy reports

Third in the staged series clearing the errors #4655 made visible.
Whole-project mypy: 91 errors in 26 files -> 64 in 23.

Twenty `# type: ignore[assignment]` comments in
endpoints/responses/rom.py never suppressed anything. The request-scoped
values `from_orm_with_request` attaches to a Rom (rom_user, has_notes,
user_saves and the rest) are not declared on the model, so mypy reports
`attr-defined`; it does so under 1.19 as well as 2.3, so the code was
wrong when the comments were written rather than drifting since. They
now name the error they were meant to silence.

Seventy-nine ignores across 24 files suppressed nothing at all under
`--warn-unused-ignores`, and are removed. One of them,
`utils/zip_cache.py`, keeps its `attr-defined` code for the private
`zipfile._get_compressor` and drops only `assignment`. The unused set is
identical under mypy 2.3.0 and 2.3.1, and removing them leaves the error
count unchanged under both, so none was quietly needed.

The two `filter` helpers typed as `[QueryT: Select | Update | Delete]`
bound the TypeVar to the union, so `query.filter(...)` returned the union
and could not be assigned back to `QueryT`. Constraining it to the three
types lets mypy check each one separately, and the callers are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPpv6W2ygP9tQ61fTQxdYp

* fix(backend): replace mypy and ASYNC240 trunk-ignores with real fixes

A `trunk-ignore` only suppresses when Trunk runs the linter. Plain mypy
does not read them, so the 13 on mypy findings were all still errors to
`mypy .` and would fail a whole-project check. Each now has a fix.

endpoints/tasks.py: `common_data` was a plain dict literal unpacked into
eight TypedDict constructors, so mypy saw `dict[str, Any]` and could not
match its keys. It holds exactly the fields of BaseTaskStatusResponse and
is now annotated as one, so the unpacking is checked.

handler/metadata/gamelist_handler.py: both media maps were inferred as
`dict[str, str]`, so indexing the TypedDict with their keys was
unprovable. Their keys are now typed `GamelistMediaKey`, the Literal of
the TypedDict's fields. A misspelt map key is now an error at the entry;
before, only the index site could have noticed, and it was suppressed.

handler/metadata/playmatch_handler.py: `attr` was a bare `str`. A TypeIs
guard narrows it to the five lookup attributes, and the frozenset is
derived from that Literal so the names live in one place. mypy now checks
that each name is a real PlaymatchRomMatch key. It does not check that
each takes an int, since mypy is lenient about value types on a union key;
that still rests on which five names are listed.

endpoints/search.py: the per-source tuples mixed ROM-list and handler
types, which mypy joined to `object`. The dict is now annotated with what
the loop uses: Mapping rows and the MetadataHandler base.

tests/handler/metadata/test_launchbox_handler.py: `Path.stat()` inside an
async test (ASYNC240) now goes through `anyio.Path`, as the rest of the
codebase already does.

Whole-project mypy: 64 errors in 23 files -> 51 in 20, identical under
2.3.0 and 2.3.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPpv6W2ygP9tQ61fTQxdYp

* fix(backend): keep gamelist media keys in one place

Review pointed out that `GamelistMediaKey` repeated all fourteen fields
of GamelistMetadataMedia. Python has no `keyof`, so any Literal of a
TypedDict's keys is a second declaration of them, and a field added to
the TypedDict would be left out of it without any error.

The three index sites go back to suppressing `literal-required`, now as
`# type: ignore[literal-required]` so plain mypy reads it as well as
Trunk. The TypedDict stays the only declaration of the key set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPpv6W2ygP9tQ61fTQxdYp

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-22 16:02:39 -05:00
Sam Dornan
552cf7c213 fix(config): show folder mappings whose folder name is not lowercase (#4676) 2026-09-21 19:52:40 -04:00
Georges-Antoine Assi
d3cda9b003 Merge pull request #4534 from rommapp/claude/fix-4398-inconclusive-scan
fix(scan): don't report an unanswered lookup as a confirmed miss
2026-09-16 19:05:45 -04:00
Georges-Antoine Assi
d6eba3297a fix(scan): treat every silent provider as inconclusive
ScreenScraper catches its own rate limit and breaker, so the miss they
cause never reaches resolve_fetch and was still written up as confirmed.
Hasheous had the opposite gap: an unanswered hash lookup still counted as
attempted, so a complete rescan cleared the id the lookup could not redo,
and a disabled handler reports the same flag as an outage without ever
having been consulted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 18:38:47 -04:00
Georges-Antoine Assi
d800d60c32 fix(scan): don't report an unanswered lookup as a confirmed miss
lookup_rom already tells a real "nothing knows these hashes" apart from a
provider that never answered, and only the HASHES de-verify guard read it.
A 429, a 500 or a timeout therefore logged the ROM as not identified in
the same words as a genuine coverage gap, and the reporter spent two days
treating transient failures as gaps. Track the sources that gave no answer
and say so in the outcome.

Retrying in-scan, or persisting a revisit marker, would change what the
nightly QUICK scan covers, so it is deliberately not part of this.

Refs #4398

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 19:44:36 -04:00
Georges-Antoine Assi
fa8001c075 fix(scan): send Playmatch as a metadata source so the UI switch works
The Playmatch switch shipped its choice as a standalone `playmatch_enabled`
flag, but the backend gates the lookup on `MetadataSource.PLAYMATCH in apis`
and nothing ever read the flag, so UI-initiated scans never queried
Playmatch. Push `playmatch` into `apis` like `hasheous`, and drop the dead
flag from the payload and the scan plumbing.

Fixes #4505

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 17:23:21 -04:00
zurdi
03d986bd55 fix: address the cover provider review
The providers row dropped a grid provider's match cover whenever that
provider was configured, even when its grid came back empty, so a
timed-out CDN probe hid the one Steam capsule the match had found. The
row now only drops a provider whose result set is actually in the grid.

A source listed twice in the cover priority handed the picker its
covers twice; the priority helper now keeps a source's first position
only, for every caller. The v1 cover dialog keys its panels by
provider as well as name, since both providers can return the same
title. The provider chips grow to the touch target on touch and
gamepad input.

The invalid-key regression test now raises the adapter's own exception
class, and the endpoint gate is covered with Steam as the only enabled
provider. A component test drives the dialog wiring: chips filter the
grid, Steam covers are handed off untouched, and the providers row
keeps a match cover whose grid is empty.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Untv32z88QMZ2yRSsTgGcC
2026-09-14 01:00:34 +02:00
Georges-Antoine Assi
892657465f fix: stage the config fixture for e2e and address review findings
The e2e job copied only the fixture library, not the config.yml declaring its
platform-folder-first layout, so the seeder scanned an empty library.

Reject `.` and `..` template sections: no directory listing yields either, so a
template carrying one discovered nothing and marked the platform's roms missing.

Drop the cached `full_path` when either half is set. A scan reads it and then
renames the file in place, which left the cached pair stale.

Point `build_physical_fs_name` at the index 0126 actually creates.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 09:11:16 -04:00
Georges-Antoine Assi
a7ecfd96a9 feat!: make filesystem.structure the single library layout
`filesystem.structure` now spells out the whole layout rather than only the part
below a platform folder. A template is relative to the library root, `{platform}`
marks the platform folder, and `{game}` marks where a game begins.

Merge `{gameFile}` and `{gameDir}` into one `{game}` terminal. The information a
terminal carried was the depth, not the kind: at a declared level a file is a
game of its own and a folder is one multi-file game, which a stat answers. That
drops the two-template idiom for a level holding both, and `_discover_default_roms`
with it, since the default scan is now just `roms/{platform}/{game}`.

Retire the auto-detected `{platform}/roms` layout, along with
`filesystem.roms_folder` and `filesystem.firmware_folder`, which named one path
segment each that a template now contains. Both are refused at startup with the
template that reproduces the layout, so an instance that relied on either says so
instead of scanning an empty library and marking every rom missing. Firmware gets
its own `structure.firmware` key rather than following the rom layout implicitly.

`get_roms_fs_structure` keeps meaning the folder a platform's games start in, so
the `.physical` sentinel paths already in the database still resolve. Per-platform
overrides have to agree with `default` on where the platform folder sits;
relocating one platform needs platform discovery and the watcher to union several
roots, which is left out.

The setup wizard reports `library_ready` plus the configured template instead of
a `struct_a`/`struct_b` discriminator, so the banner shows the layout in force
rather than guessing it client-side.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 08:39:21 -04:00
Georges-Antoine Assi
f105622513 fix: address code review on the library structure unique index and relocation
Key the unique roms index on a sha256 digest of the full path. Indexing
(platform_id, fs_path, fs_name) directly is 5804 bytes of utf8mb4, which MySQL
rejects with ER_TOO_LONG_KEY and MariaDB silently demotes to a hash index; the
digest column keeps it a 260-byte BTREE on every supported driver. It is derived
by the same @validates hook that maintains the other fs_name columns, and
resynced explicitly in update_rom and convert_rom_to_folder.

Migration 0126 backfills the digest in one dialect-branched UPDATE. A Python
executemany right after the ADD COLUMN silently applies only its first parameter
set on mariadb-connector, leaving the rest NULL. test_migrations pins the SQL
expression to compute_full_path_hash so the two cannot drift.

Drop the relocation pre-pass. mark_missing_roms already runs before the identify
loop, so a moved file reaches get_matching_missing_rom, which requires all three
hashes to agree (or a title_id, covering non-hashable platforms), refuses
ambiguous matches, re-parses filename tags and emits over the socket. The
pre-pass duplicated it with a weaker CRC-only check, hashed every candidate
twice, compared folder sizes against a total that excludes filtered files, and
ran on QUICK scans.

Send uploads to a folder the platform's structure will actually discover, so the
next scan does not flag a fresh upload as missing, and refuse with a 400 when
only the user can pick the folder.

Make 0126's downgrade refuse when duplicate file names exist instead of deleting
the roms (and their saves, notes and collection membership) that carry them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 19:14:58 -04:00