* fix(scan): reuse unchanged empty files on quick scan
An empty file hashes to the default digest, which _make_file_hash stores
as a blank md5. rom_file_unchanged required a non-blank md5 on hashable
platforms, so an empty top-level file in a folder ROM (for example an
MSU-1 .msu) never counted as unchanged. The whole folder was re-hashed
and the ROM re-emitted on every quick scan, pushing it to the front of
Recently added.
Treat a zero-byte file as already hashed. Stored hashes stay blank so the
empty-input digest never feeds hash-based metadata matching.
Fixes#4933
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mre6qcBuXvGJzBJjJfkDvy
* docs(scan): name _make_file_hash as the source of blank empty-file hashes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mre6qcBuXvGJzBJjJfkDvy
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* perf(gamelist): validate media tag paths once per directory
A full-platform gamelist parse ran validate_path on every media tag,
about a dozen lstat calls each, which added up to tens of seconds per
platform on NFS/SMB mounts.
FSHandler.cached_path_validator returns a validate_path equivalent that
runs the lexical checks per call but hits the disk once per distinct
parent directory. The leaf needs no syscall: validate_path accepts a
symlinked leaf, and a plain one resolves inside its checked directory.
The gamelist parse builds one per pass and threads it to the media tag
and directory-entry checks.
On a 1,500-entry gamelist with six media tags per entry, lstat calls
drop from 108,140 to 200.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5CmSdodtG5s2MiH9y65LE
* test(gamelist): pin one validate_path call per media folder
Condense cached_path_validator's docstring to one sentence, and assert
the exact per-folder call counts in the gamelist parse test, with the
media index stubbed so only the parse's own validation is counted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5CmSdodtG5s2MiH9y65LE
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* perf(scan): read only the selected ROMs' gamelist entries
A scan of hand-picked ROMs warmed the gamelist cache by parsing the
platform's whole gamelist.xml. Every media tag of every entry goes
through validate_path, which stats each path component, so a 1,500
entry gamelist costs ~160k lstat calls. On a network mount that stalled
a one-ROM rescan for ~45 seconds before hashing started.
populate_cache now takes the file names to limit the parse to, and the
cache records that scope so a lookup outside it (a ROM renamed mid-scan,
or an overlapping library scan) still parses the full file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KakznhQRBWTSARmmsYLXHQ
* perf(scan): widen a limited gamelist cache instead of reparsing it all
A selected ROM renamed mid-scan (Switch title-ID embedding) is looked up
under a name outside the cache's scope, which fell back to a full parse
and brought the stall back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KakznhQRBWTSARmmsYLXHQ
* perf(scan): widen a limited gamelist cache by the missing names only
Each widening re-resolved every name already cached, so a batch of
Switch ROMs renamed mid-scan cost quadratic media resolution. Only the
names the cache lacks are read now, merged into the cached entries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KakznhQRBWTSARmmsYLXHQ
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
- Match on (issuer, sub) with exact collation, so subjects from another
provider or differing only in case never match.
- Refuse a login whose email is linked to another subject at the same
issuer instead of rebinding the account; relink only across issuers.
- Check the account is enabled before saving identity changes.
- Keep the old email when it is claimed between the check and the write.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Store the provider's `sub` on a new nullable users.oidc_sub column, look users
up by it first and fall back to email, backfilling the sub on the next login. A
user matched by sub gets their stored email updated, unless another account
already holds it.
Fixes#1690
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Keep email_verified tied to the email it came with, and fall back to the
ID token claims when provider discovery fails as well.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Providers like Authelia follow OIDC Core 5.4 and return scope claims
(email, preferred_username, groups) only from the UserInfo endpoint.
When any claim RomM reads is absent from the ID token, fetch UserInfo
with the access token, check that its sub matches, and merge it under
the ID token claims.
Fixes#1927
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* Run the chroma-key placeholder check off the event loop
_discard_if_chroma_key decoded every stored media image synchronously
inside an async method, so each check (about 15 to 35 ms for a 1024px
screenshot or box face) stalled the event loop and every other request or
scan task running on it. The decode now runs through asyncio.to_thread,
like the cover and logo work in the same handler.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* Hold the file lock across the chroma-key check and delete
With the check awaited on a worker thread, a concurrent writer could
replace the file between the verdict and the delete, and the replacement
was then removed on the old file's verdict. The existence check, the
decode and the unlink now run under the path's lock, and a test replaces
the file mid-check to prove the new artwork survives.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* Make the chroma-key replacement test independent of timing
The test slept 0.2s and hoped the writer had run by then; a slow writer
would let unlocked code pass. It now asserts the path lock is held during
the check before the writer starts, and that the writer cannot finish
while the check runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Show the scraped game logo in place of the title on the v2 game page
When a ROM has a ScreenScraper wheel (ss_metadata.logo_path), the details
header renders it inside the h1, with the game name as alt text, and falls
back to the text title when there is no logo or it fails to load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* Trim the transparent border off stored game logos
ScreenScraper wheels often sit on a padded 1024x512 canvas, so a logo shown
in place of the game title looked indented and smaller than its neighbours.
store_metadata_media now crops each logo to its visible pixels, including
logos already on disk, so a rescan fixes existing libraries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* Put the logo-as-title display behind a UI setting, off by default
Adds a showLogoTitle entry to useUISettings (synced to the user's
ui_settings like the other display preferences) and a 'Show logo as
title' toggle in the Gallery section of the User Interface settings, with
the new strings translated in every locale. GameHeader shows the logo only
when the setting is on. Also clears the existing em-dashes from
UserInterface.vue comments, which the lint rule flags once the file changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* Outline the title logo so dark or light lettering stays readable
Some ScreenScraper wheels carry thin black text (A Link to the Past's
subtitle) that vanished on the dark theme, and white lettering has the same
problem on the light one. The logo now gets a 1px rim in the theme's text
colour, replacing the soft drop shadow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* Size the title logo by area so square logos match wide ones
A shared 128px height cap left near-square wheels (A Link to the Past,
Aria of Sorrow) with about half the area of wide ones. Once the logo loads,
GameHeader now sets its width so every logo covers roughly the same area
(40,000 px, 22,000 on phones), within a 176px (120px) height cap and the
existing 420px width cap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* pr-ready step 2 (code-review): harden logo trimming and logo retry
- Share one IMAGE_DECODE_ERRORS tuple (adds SyntaxError and
DecompressionBombError) across the image helpers, so a broken or
oversized logo no longer aborts store_metadata_media.
- Trim under the per-file lock and replace the file atomically, so a failed
save keeps the original and a hardlinked source is never cropped.
- Skip every multi-frame image, and crop in the image's own mode so palette
logos stay compact.
- Reset the header's logo failure and ratio whenever the logo URL changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* pr-ready step 3 (simplify): share the resource URL helper, trim dead code
- Add versionedResourceUrl to v2/utils/romFiles and use it from GameHeader,
romArtwork and ManualSubtab, so the scraped-media cache-bust rule has one
home.
- Key the header's logo load state on the URL (failedSrc, loadedLogo)
instead of resetting two refs from a watch; hoist the shared 420px cap.
- Drop logo CSS the inline sizing made dead (display, height, object-fit,
object-position).
- Read the alpha bbox with getbbox instead of a full RGBA copy, and check
transparency before counting frames.
- Use a handler fixture in TestTrimTransparentBorder.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* pr-ready step 4 (review-polish): drop a filler comment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* pr-ready step 5 (humanizer): state three comments directly
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
* Bound logo trimming by pixel count and test phone logo sizing
- Skip trimming a logo above MAX_TRIM_PIXELS (16M), checked from the image
header before any pixel is decoded, so a large download under Pillow's
decompression-bomb threshold can't exhaust worker memory mid-scan.
- Cover the xs area and height cap in GameHeader's sizing tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* 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
The grouped gallery's dedup window ranked every sibling before the
per-user status/hidden filter ran, so hiding the rom that won row_num = 1
removed the whole group even when visible siblings existed. The same
happened with a status filter matching only a non-primary sibling.
Build the per-user visibility predicate once and use it to rank matching
siblings first in the window, mask the group sort aggregate, and filter
the outer query. The window's base subquery is unchanged, so the covered
dedup plan is unaffected.
Fixes#4466
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ScreenScraper has no dedicated system for the Commodore 128 or the
Videopac+ G7400, so both reuse a sibling's system ID (C64 and G7000).
The mapping copied the sibling's name too, and since IGDB has neither
platform, that ScreenScraper name won the display-name fallback. The
setup wizard and platform picker then listed the c128 slug as
"Commodore 64" and videopac-g7400 as "Videopac G7000".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
When extracting the largest member of a .7z failed partway, the bytes already
streamed stayed in the file and ROM-level hashers, and the raw-archive
fallback was appended on top, giving a hash that matched neither. The hashers
are now restored to their pre-extraction state before the fallback runs.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(backend): pipeline multi-command Redis writes
- upload_chunk records a chunk with SADD, EXPIRE and SCARD in one
transaction instead of three round trips, so a failure between them
can no longer leave the chunk set without a TTL.
- bind_to_login_session does its SADD and EXPIRE in one transaction for
the same reason.
- close_login_sessions reads and deletes a session's socket set in one
transaction, so a socket binding in between is not dropped unseen.
- Logout deletes the session and removes it from the user's set in one
pipeline.
- complete_chunked_upload reads the chunk set once instead of SCARD then
SMEMBERS; cancel and invalidate_filter_values_cache delete their keys
in one call.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv
* fix(backend): refuse a socket bind that lands after its session's revocation
- bind_to_login_session checks the login session still exists in the
same transaction as its SADD. Revocation deletes the session before it
reads the socket set, so a bind that finds it gone removes itself and
authenticate treats the socket as anonymous.
- complete_chunked_upload keeps its SCARD fast path and reads the
members only to name the missing chunks.
- cancel_chunked_upload removes the temporary files before touching
Redis.
- Tests check each pipelined write executes as one MULTI/EXEC.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv
* fix(backend): close an upload session before removing its files on cancel
A chunk PUT that passes the session check after the temporary directory
is gone fails with a 500; deleting the session first turns it into a 404.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv
* fix(backend): answer a chunk write cut short by a cancel with 404
A PUT that passed the session check before the cancel removed its
directory fails writing; it now re-reads the session and returns the
same 404 as a PUT that arrives after the cancel, instead of a 500.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv
* chore(backend): remove a stray Redis snapshot
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Recompute the folder category for rows a Quick scan reuses, so files
categorized before the anchor fix are corrected without a Complete scan,
and annotate the new tests' parameters.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A broker too old to name its core also doesn't refuse a pushed state from
another core, so hydration with no core filter now only sends a newest
state that has no recorded core, and otherwise sends nothing.
A RetroArch container's core filter comes from the core activate reports
booting, or before launch from the configured core and the broker's
default (asked over its cores route and cached for a minute). Hydration,
an explicit resume and the config payload all apply it, so a state
written by one core never lands where another core's quick-load reads it.
A resume the booted core cannot load launches fresh, and the resume
endpoint refuses such a state up front with a 400.
States gain a nullable `core` column (migration 0141). A pulled state keeps
the core the broker names in its X-State-Core header, and a pushed state
names its core on the way down so a broker running another one refuses it.
NULL keeps meaning the platform's default core, which wrote every state
stored before cores were recorded.
- Retry the exit once when a broker boots the wrong core and the first exit
fails: the broker refuses every activate while that game runs, and the
released claim leaves nothing behind to stop it.
- Stamp the launch's core tier on the session and report it through the
status poll, so a tab that missed launch-ready still warns about an
untested or broken core, once.
- Translate the core-untested and core-blocked warnings in every locale.
- Replace the inline bytes-to-text decodes with redis_handler.as_text
- Add utils.auth.token_device_id for a request's token-bound device
- Look up a group's member tokens in one query and close them in one pass
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Share one watched-transaction retry loop and live/gone split in the install handler
- Emit independent socket events concurrently
- Drop the dialog's redundant close watcher and repeated current-rom checks
- Reuse the add_device_token fixture and shared header fixtures in tests
- Fix mypy errors in the socket and handler tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
category_for_path_parts matched every segment of the library-relative
path and returned the first hit in enum order, so inner dump folders
(content/Game, content/CMCmn/demo), the rom folder itself, or even the
platform folder could set a file's category, and a bare `game` segment
outranked an `update` or `dlc` folder above it.
The scanner now passes the path relative to the ROM root, and only the
top folder there decides the category; deeper files inherit it.
Fixes#4581
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ScreenScraper's dedicated "PC Win9X" system (137) holds very few games;
Win9x titles are filed under the generic "PC Windows" system (138), which
acts as a fall-through like MAME does for arcade. Searching 137 meant
Win9x games only matched when scraped by ID.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(hasheous): match multi-file roms when one file is unknown
Hasheous' /Lookup/ByHash returns 404 for a batch as soon as any one SHA-1
in it is unknown, even when the rest match. A multi-disc CHD set with an
.m3u, a readme or an off-set disc beside it therefore never matched, e.g.
Final Fantasy VII (USA), whose three MAMERedump CHD hashes match on their
own.
- Leave .m3u playlists out of the lookup.
- When a multi-file batch misses, retry each file on its own, largest
first, and take the first match.
- Read the TheGamesDB id from "TheGamesDb", the spelling Hasheous returns,
so tgdb_id is no longer always dropped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZeLXgA178Biwj7eUReck4
* fix(hasheous): require per-file matches to agree on one game
The per-file retry took the first file Hasheous knew, so a folder holding
an unknown game next to a known file from another game (a demo disc, a
bonus CD) could take on that other game's ids. Every file is now asked
and the match stands only when all known files name the same game;
conflicting answers match nothing and leave the lookup inconclusive.
A failed per-file request still ends the lookup as inconclusive, since
agreement can't be vouched for without every answer. The largest-first
ordering is gone, as nothing depends on the order any more.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZeLXgA178Biwj7eUReck4
* test(hasheous): expect the per-file retry after a missed batch
test_lookup_rom_sends_all_top_level_file_hashes mocks a miss for two
files, which now also asks Hasheous about each file alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZeLXgA178Biwj7eUReck4
* test(hasheous): build lookup fixtures as real RomFiles
The lookup tests cast MagicMocks to RomFile, which would hand lookup_rom
attributes a real RomFile lacks. They now build RomFiles, so file_extension
and lookup_hashes come from the model itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZeLXgA178Biwj7eUReck4
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
- Reject installs of a rom missing from the filesystem
- Keep a request created during a device discard indexed
- Hold a strong reference to the device socket keepalive task
- Never raise from emit_permissions_changed after a committed change
- Map only a missing install request to 404, not any KeyError
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* 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(deps): bump redis to 8.1 and fakeredis to 2.38
redis-py 6.2.0 -> 8.1.0 and fakeredis 2.30.1 -> 2.38.0. RQ 2.12
(redis!=6,>=3.5) and fakeredis (redis>=4.3) both accept redis 8.
fakeredis 2.38 types FakeServer's version argument as a tuple, so pass
(7,) instead of 7. Behaviour is unchanged since fakeredis normalises an
int to a one-element tuple.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014wzuPg8vDEjsQ8xqvZgFwx
* chore(deps): drop types-redis in favour of redis-py's own types
types-redis only covers redis 4.6 and shadowed the inline types that
redis 8 ships, so mypy was checking calls against a stale API. Removing
it also drops its transitive stub packages (types-cffi, types-pyopenssl,
types-setuptools), which nothing else uses.
redis-py's types differ from the stubs in three ways:
- Redis, AsyncRedis and Pipeline are not generic, so drop the [str] and
[bytes] parameters.
- Responses are typed bytes | str regardless of decode_responses, so cast
at the few call sites that rely on the decoded (or raw) type.
- watch, unwatch, multi, aclose and execute_command are unannotated, so
add redis to untyped_calls_exclude, as is done for rq and apprise.
Also replace setex, deprecated in redis 8, with set(..., ex=...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014wzuPg8vDEjsQ8xqvZgFwx
* fix(device-auth): replace deprecated GETSET with SET ... GET
code-review step. GETSET is deprecated since Redis 6.2 in favour of
SET with GET. Using it with ex= also sets the poll key's TTL in the same
command, instead of a separate EXPIRE that a crash could skip.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014wzuPg8vDEjsQ8xqvZgFwx
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>