* 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>
Importing any handler.auth submodule ran the package __init__, which
built the auth handlers and so loaded authlib, joserfc and Socket.IO.
models.user imports handler.auth.constants, so every process that
touched the models paid for the whole auth stack. The handler
instances now live next to their classes in handler.auth.base_handler.
utils.context imported fastapi only for annotations; that import now
sits under TYPE_CHECKING.
An idle RQ worker drops from about 118 MB to 89 MB RSS. Each job's
forked work horse now imports a little more on its own, about 0.2s
on an x86 host.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gh1SRMfuK7BZmf6YxMqSyT
Tests, fixtures and the e2e seed found the seeded groups by display name,
which an admin can edit and this PR just changed. A unique system_key
column (viewer/editor), added and backfilled by 0137, identifies them
instead, and get_system_group() replaces the name lookups.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The e2e seed resolves the viewer via get_default_group instead of a list
of fallback names. The migration drops the id pre-select, and the tests
load the revision once and call upgrade/downgrade directly.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Master already chains 0135 and 0136 onto 0134, so the rename becomes
0137 revising 0136_deleted_assets to keep a single alembic head. Also
dedupe the migration filename in tests, rename tests that still said
legacy, and drop em-dashes and a long docstring.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Address Greptile review: the e2e seed could pick an admin-created "Viewer"
group, the migration docstring recounted history, and the conflict test
compared a description with itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xdb9FnfhEqP6ectkSZ2T3F
Every install showed "Viewer (legacy)" and "Editor (legacy)" as the built-in
groups, which reads as deprecated. 0092 already shipped in 5.3.0, so a new
revision renames the untouched system rows and drops the "pre-upgrade"
framing from their descriptions. It skips a group whose target name an admin
already took, and keeps a description the admin edited.
Fixes#4678
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xdb9FnfhEqP6ectkSZ2T3F
They exist to stand up a disposable instance for the Playwright suite, so
they belong with the workflow that runs them rather than in backend/tools/
next to the library-generation utilities.
Their sys.path bootstrap now points at backend/ explicitly (it relied on
being one level below it), the workflow invokes them from the repo root
instead of backend/, and .github/scripts/** joins the workflow's path
filters so editing a seeder still triggers the suite.