* 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>
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
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>
Identify demoscene productions as ROMs via filename tags, Edit-ROM
id/URL paste, Demozoo ?title= + rank, unique Pouët search.php 302,
and CSDb XML by id (no HTML scrape). Scene ids lock name/summary/cover
so game catalogs cannot attach a similarly titled box.
CSDb XML is parsed with defusedxml and capped; screenshot and extra
links are stored only when they are http(s).
Fixesrommapp/romm#1796 (Phase 0–2).
Unknown provider slugs in scan.priority.cover/screenshot/manual are
already dropped by the downstream availability filter, so they never
crash a scan, but they silently did nothing. Surface likely typos with
a load-time warning, consistent with scan.media handling. A drift-guard
test keeps VALID_SCAN_PRIORITY_SOURCES in sync with MetadataSource.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add optional scan.priority.cover / screenshot / manual keys that each
override scan.priority.artwork for a single artwork field, falling back
to the shared artwork priority when omitted. This lets users, for
example, keep original box art for covers while sourcing screenshots
from a different provider.
Backward compatible: absent keys leave behavior unchanged. Config-only
(no UI), read-only exposure via GET /api/config.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>