* 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>
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
* 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>
* 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>
* 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>
* 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>
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>
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>
- 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>
- 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>
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>
* 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>
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>
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>
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>
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
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>
`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>
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>
Conflict resolution notes:
- Locale rom.json: master sorted and reworked every file; took master's and
re-inserted `location` / `location-copied` in sorted position. Added them to
the new tr_TR locale.
- FSRom gained a required `fs_path`, so `build_hashless_fs_rom` now takes one
and both call sites pass the rom's own path.
- `get_roms` keeps this branch's `_collect_fs_roms` discovery while adopting
master's one-pass build and in-place sort.
- `mark_missing_roms` takes full paths and now also excludes physical games
(master), and the scan loop keeps master's early missing-sync plus its
restored-rom emit alongside this branch's relocation pass. The relocation
filter now applies only to the identify loop, so a relocated rom is no longer
re-flagged missing at the end of the scan.
- Relocation writes rom files through master's `sync_rom_files` (which replaced
`purge_rom_files` / `add_rom_file`), so row ids and track metadata survive.
- Master's unique index on (platform_id, fs_name) contradicts this branch's
premise that same-named files in different folders are distinct games.
Migration 0126 widens it to (platform_id, fs_path, fs_name); physical games
all share one folder, so a duplicate title is still rejected.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The resolver took the provider names as a second tuple that had to stay in the
same order as the gather, which a reordered lookup would silently break. Pairing
the name with its coroutine follows the shape scan_handler already uses for
provider_fetches, and folds the gather into the resolver.
Also trims the comments and docstrings the review pass flagged as over-long.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A tripped breaker answers in ScreenScraper's place, so the empty match it
produces is not a miss and must not clear the rom's stored ss_id. The scan
learned that by sampling the module-wide is_breaker_tripped() at three points,
which reads another rom's trip as this rom's evidence.
SSHandler now raises ScreenScraperExhaustedError instead of swallowing the
breaker's error, carrying the match it would have returned so the name the
filename lookup derives locally (Switch title database, MAME, PS2 OPL) still
reaches the scan. fetch_ss_rom catches it the way it already catches
ScreenScraperRateLimitError, and drops ScreenScraper from attempted_sources
from a plain local, so the signal is exactly this rom's own lookups.
Also folds in a cleanup pass over the branch: the dead default_factory arm in
_ScanState.reset(), one home for the ssuserInfos.php path, asyncio.wait_for
around the quota probe so it cannot block behind a media download holding the
concurrency slot, and shared fixtures for the ScreenScraper tests.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
HTTP 431 means a ROM did not match and the daily cap on proposing unknown
ROMs for review is reached; scraping is unaffected, so it becomes a
not-found with one informational line per scan instead of a refusal that
takes the provider out.
HTTP 431 is really two answers at once and only one of them concerns the
scan. The scrape allowance (430) still trips a breaker, since every
remaining ROM would otherwise cost a round trip to be told the same thing,
but it now arms only after repeated refusals, ignores the ones already in
flight when a refusal was counted, and re-checks the free account endpoint
so it recovers without a scan to reset it. The account check can no longer
arm it at all.
A recoverable breaker can clear itself while a rom is still gathering its
other providers, so a complete rescan read it as having answered and wiped
the rom's id. It is now sampled where ScreenScraper is consulted.
The manual-match search gathers every provider without return_exceptions,
so it now swallows an exhausted ScreenScraper the way the scan lookups do.
Fixes#4123
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Backend:
- One session-scan iterator (`_iter_session_keys` / `_iter_live_sessions`)
replaces three copies of the Redis scan-and-decode loop, and
`_get_live_session` replaces five independent "a drain marker is nobody's
session" checks.
- `_abort_claim` replaces seven inlined claim-abort cleanups, so a new failure
branch can no longer wedge a container and orphan a blank card.
- `_quiesce_container` and `_collect_exit_state` replace the stop-evacuate-wipe
and guarded state-pull blocks written out in all three teardown paths. The
`_record_termination` calls stay at the call sites: the three order it
differently and each has its own reason.
- `_hold_reservation` / `_drop_reservation` collapse the two
release-after-state-pull helpers into one, and absorb the third copy of that
branch inlined in the released-session teardown.
- `_load_state_broker`'s two protocol branches were byte-identical, so it now
takes its route from `_transfer_route`; `_raise_broker_http_error` and
`_raise_broker_unreachable` replace the error translation copied into
`_call_broker` and `_webstation_activate`.
- `_container_labels` builds the label map once per request rather than
re-reading and re-parsing config.yml for every listed row.
- The joinable listing fetches each ROM once, through `get_rom_simple` rather
than the `@with_details` query, for five columns.
- `store_memory_card_version` hands the hash it computed in memory to the scan,
which was reading the archive back off disk to recompute it.
- `_prune_state_history` takes the history its caller already fetched.
- `playlist_files` in utils/m3u.py is now the one home for "which files are
discs", shared by the download endpoint, the m3u generator and the swapper.
Frontend:
- `useActivityPresence` replaces the presence block copied verbatim from
EmulatorJS.vue into Stream.vue.
- `MemoryCardNameDialog` replaces three copies of the same name-entry dialog.
- The two private axios error extractors give way to the `errorMessage` util,
three hand-rolled spinners to `RSpinner`, six manual listener pairs to
`useEventListener`, and five copy-on-write Set/Map trackers to `reactive`.
- `keepaliveHeaders` moves next to the interceptor that owns the CSRF header.
- The exit chord polls at 10Hz instead of every frame, the stage measures its
offset once instead of per mousemove, `postToStream` reuses the frame list
the attach pass walked, and the admin/home polls skip a hidden tab.
- `containerLabelForPlatform` on the store replaces the two `streamLabel`
definitions that answered differently, and the stream/join action labels move
onto useGameActions so the button and the menu cannot word them differently.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Conflicts and how they were resolved:
- `useGameActions`: master renamed `useCanPlay`'s `canPlay` to `canPlayLocal`
and kept a local `canPlayStream`, while this branch moved `canPlayStream`
into `useCanPlay` and folded it into `canPlay`. Kept this branch's shape and
took master's `useScanTrigger()` call.
- `Player/Stream.vue`: kept this branch's force-release and session-poll block,
and re-placed master's `useUnloadGuard(sessionActive)` next to the
`sessionActive` watch.
- `locales/*/play.json`: kept both sides' keys, re-sorted.
- `__generated__/index.ts`: kept both sides' model exports, re-sorted.
- `test_config_loader.py`: kept both sides' tests.
Master took 0114 through 0118 while this branch was open, so its three
migrations are renumbered 0119-0121 and rechained after
`0118_rom_category_cheat_pg`, leaving alembic with a single head.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every gathered provider already resolved through a single loop that logs the
failure, drops the source from the attempted set and falls back to an empty
match. SteamGridDB, which searches on the names the other providers produce and
so cannot join that gather, hand-wrote the same three steps again, and the
search endpoint hand-wrote a third copy. Extract the loop body into
`resolve_fetch` and route SteamGridDB through it.
In the search endpoint the cover gathers now tolerate exceptions instead, so a
failed lookup costs a thumbnail rather than the whole result set. That also
covers Libretro, whose lookup had no guard at all and could fail the request.
On the test side, the platform, rom and `fs_rom` scaffolding was written out
three times across the two scan tests; it now lives in `tests/handler/scan_stubs.py`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fold the folder name resolution into one home and make it case-insensitive
end to end.
Config folder names are lowercased as the config is parsed, so bindings,
versions and the built-in alias table are all matched the same way. A SNES/
folder now resolves, and a binding written GameCube: matches a gamecube/
folder.
Add resolve_fs_slug(), the inverse used to recover a renamed folder, which
replaces the two swapped dicts in scan_platform. Only slugs reached by
exactly one folder name are reversible, so recovery never guesses between
amiga500, amiga600 and amiga1200.
Validate system.platforms and system.versions through one helper that
rejects empty and non-string values, and treat a null block as empty rather
than exiting.
Restore the atari800 override in the example configs: its folder name is
itself a RomM slug, so it can never be an alias. A new test derives the
needed overrides from the alias table to keep the examples honest.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A complete rescan clears the id of every source it consulted that came back
empty. That reads an outage as a conclusive miss for the providers that report
a failure as an empty match, so a rescan run while one was down wiped the id it
would otherwise have confirmed, hand-set ones included.
Each of those now reports the failure and leaves the tolerance to the caller,
which is what the gather loop's discard already assumed:
- Pouët, CSDb and Demozoo stop swallowing the 503 their own `_request` raises,
and Pouët's title search raises it rather than answering "no unique title".
- SteamGridDB and Flashpoint stop catching `Exception` around a whole lookup;
HLTB stops catching it around its search.
- ScreenScraper answers empty for every remaining ROM once its daily-quota or
credentials breaker trips, so the scan reads that state off the service and
drops it from the sources the rescan may clear.
SteamGridDB resolves outside the gather and so needs the discard at its call
site. Search keeps degrading to no thumbnail, since its cover art sits on top
of matches the other providers already produced.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A complete rescan is documented as wiping every external id and matching
again from scratch, but it only wrote NULL for deselected sources. Selected
ones were assumed to reset implicitly by staying out of rom_attrs, which
merge then skips rather than nulling, so a provider that searched and found
nothing left its old (wrong) id in place.
Track the sources whose lookup actually ran and clear those too. A source
skipped because the platform carries no id for it never enters the set, so
hand-set ids on unmapped platforms survive, and a provider that raised or
hit the ScreenScraper rate limit is discarded again since it ruled nothing
out. SteamGridDB resolves after the reset block, so it clears its own id.
Fixes#4346
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Master moved UniversalPlatformSlug to utils/platform_slugs.py so that naming
a platform no longer imports the metadata stack. The alias table and its
test now import the enum from there, and utils/platforms.py keeps both the
new leaf import and the resolver import.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Frontend system folders such as gamecube, megadrive or n3ds only became
RomM platforms after the user copied a 100+ line system.platforms map into
config.yml. A built-in alias table now covers the folder names those
frontends use, seeded from the two example configs and cross-checked
against the upstream system lists.
Resolution order is unchanged for existing users: config bindings and
versions win, a folder name that already is a slug keeps matching itself,
and only then is the alias table consulted. The two call sites that
resolved folder names by hand share one resolver.
The example configs shrink to genuine overrides. The Batocera example
also mapped odyssey2 to the original Odyssey; the alias points at
Odyssey 2.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The Tinfoil feed was left behind when `_switch_productid_format` changed
from taking a `re.Match` to taking a `str`, so `/feeds/tinfoil` raised a
TypeError for any Switch rom carrying a product id in its filename but no
titledb id. It went unnoticed because `feeds.py` sits outside the changed
files mypy sees.
That call site was reachable only because "prefer the id the scan read over
the one scraped from the filename" lived in a second helper above the lookup,
leaving each caller to remember it. The resolution now happens inside
`_switch_productid_format`, so the three providers and the feed all get it
without repeating a preamble.
Also:
- Move `SWITCH_PLATFORM_SLUGS` to the sigil adapter so `utils/switch.py`
stops importing the metadata base handler. The cycle that import created
was papered over with a function-local import, and `normalize_identity`
now takes the fact it needs rather than the whole slug set.
- Merge a partial identity update onto the stored identity before
normalizing it. Normalizing rewrites the whole triple, so a client sending
only a title id was getting the derived base id next to its old save
target.
- Add `RomIdentity.from_rom` so the triple has one home on the read side
too, and drop `asdict` from `as_rom_attrs`.
- Hold the `SigilExtractionResult` on `TitleIdEmbedCandidate` instead of
copying two of its fields.
- Drop a guard in `_rom_level_identity` that could not fire, derive once in
`normalize_identity`, and return only the parse from `_rebuild_rom_files`,
which already owns `fs_rom["fs_name"]`.
- Read the parsed config in the heartbeat rather than forcing a YAML
re-parse per request, and make `SigilService.is_enabled` a classmethod
like every other one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The optional binding used to no-op in silence: an absent sigil was
indistinguishable from a file with no title id. `SigilService.is_enabled`
plus `FILESYSTEM.TITLE_ID_EXTRACTION_ENABLED` on the heartbeat put the
feature on the same footing as every other optional capability, and give
a client of `PUT /roms/{id}/identity` a way to ask whether the server
reads binaries at all.
The extracted id also reaches the layer that already matches on Switch
product ids. Until now that layer could only scrape one out of the
filename, which made `embed_switch_title_ids` the de facto transport:
users had to let RomM rewrite their filenames for matching to improve.
`switch_product_id` prefers the id read from the binary, so extraction
helps everyone with the binding and the rename stays cosmetic.
MobyGames' `get_rom` takes the rom, like its IGDB and ScreenScraper
siblings, and the product-id lookup now happens only on Switch.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`RomIdentity` replaces the title_id / save_target / save_target_layout
triple that was spelled out separately on `ParsedRomFiles`, in `FSRom`,
and again in the scan's attribute merge.
`switch.normalize_identity` is now the single place that forces a Switch
id onto the base game's, which both the scan and `PUT /roms/{id}/identity`
call. The rule was written twice before, and the two copies disagreed
about what an update's save target should be. The endpoint keeps its
merge semantics: an omitted field is still left alone.
`get_rom_files` is a read again. It records which files can carry their
title id, and the new `embed_switch_title_ids` step performs the renames,
so writing to the user's library is a named call the scan makes rather
than a side effect smuggled out on a parse result.
The Switch family now lives in `utils/switch.py` in RomM's own terms,
instead of being recovered by filtering the sigil adapter's slug map.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
scene_locked was computed only from the current scan's matches, so a Demozoo
outage on a rescan released the lock and let the catalogs write the cover, and
on a complete scan the name and summary, of an already identified production.
Base the lock on the persisted ids as well; deselecting the source on a
complete rescan clears them, which stays the way out.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds the MemoryCard/MemoryCardVersion models and migration, a database
handler, and the /api/memory-cards endpoints for creating, renaming,
sharing, downloading and uploading a card. Cards are scoped to a user
and emulator rather than a rom, since one card holds every game's saves.
Also streams zip entries when hashing so a compression bomb cannot
exhaust memory, and adds a CLI helper for importing an existing card.
Upstream took 0113, so the sigil migration rechains onto
0113_roms_locked_fields as 0114. The sigil build stage keeps its place
ahead of the emulator stage, which upstream renamed for js-dos.
Renumber the two migrations onto master's head: 0108/0109 collided with
0108_roms_primary_region and 0109_rom_files_category_index, leaving the
chain with two heads. They are now 0114 and 0115 behind 0113.
Both rebuild the roms_facets sync triggers from a hardcoded column list,
so add the publishers and developers columns 0112 introduced. Without
them the rebuilt triggers would have silently stopped mirroring the two.
Adopt master's provider taxonomy. METADATA_PROVIDER_GROUPS now carries
demozoo, pouet, and csdb as catalogs, which replaces the branch's own
GENERAL_PROVIDER_KEYS set and feeds the setup wizard, the scan dialog,
and Settings from one registry. CSDb reaches the scan explainer for the
first time; it was already selectable there.
Regenerate the frontend types: DetailedRomSchema was missing the three
metadata blobs the backend has always declared on RomSchema, and the
blobs are now typed rather than Record<string, unknown>.
Correct the setup strings that still called the three sources enabled by
default, and sort the locale keys.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>