Commit Graph

11041 Commits

Author SHA1 Message Date
Georges-Antoine Assi
117f420dca Merge pull request #4013 from rommapp/fix/hashes-scan-rematches-hasheous
fix(backend): re-run the Hasheous hash lookup on a hashes scan
2026-07-30 19:23:56 -04:00
Georges-Antoine Assi
50d4372b2b refactor(backend): drop redundant comment on the hashes scan gate
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 19:18:40 -04:00
Georges-Antoine Assi
11f570fede fix(backend): clear a stale Hasheous match when a rehash no longer matches
A rehashed ROM whose new hashes no longer match Hasheous kept its old
`hasheous_id` and `hasheous_metadata`: the merge loop only writes truthy
values, so an empty match cannot overwrite the values seeded from the
existing ROM, and the verification flags stayed on a ROM that no longer
earned them.

Clearing on any empty match would be wrong, though: `lookup_rom` returns the
same empty fallback whether Hasheous answered "unknown hashes" or was simply
unreachable (#2236), so an outage would silently de-verify a whole library.
Have `lookup_rom` return whether it reached a definitive answer, mirroring
`meta_ss_handler.lookup_rom`, and only clear the match on a conclusive miss.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 19:13:57 -04:00
Georges-Antoine Assi
8f2a361c79 Merge pull request #4012 from rommapp/fix/v2-prev-next-game-buttons
feat(v2): previous / next game buttons on the details page
2026-07-30 19:05:36 -04:00
Georges-Antoine Assi
aae4d1d9f4 fix(v2): gate prev/next arrows on real gallery provenance
The gallery store keeps `romIdIndex` alive after the user leaves the gallery,
so membership in that list wasn't evidence the user was still browsing it: a
ROM opened from Home, Activity or a scan result could inherit the previous
gallery's neighbours and offer to step through a list it has nothing to do
with. Track how the details chain was entered and require a gallery
click-through, while leaving rom-to-rom hops and play sessions armed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 18:37:16 -04:00
Georges-Antoine Assi
1a4bf1b8dd Merge pull request #3993 from rommapp/fix/permission-gaps-5.1.0
fix(security): close three permission gaps found auditing 5.1.0
2026-07-30 18:30:58 -04:00
Georges-Antoine Assi
eba61d9d3a Merge remote-tracking branch 'origin/master' into fix/permission-gaps-5.1.0
# Conflicts:
#	backend/tests/tasks/test_cleanup_orphaned_resources.py
2026-07-30 18:22:50 -04:00
Georges-Antoine Assi
c67e49c461 fix(tasks): gate the orphaned-resources cleanup on its config flag
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 18:21:39 -04:00
Georges-Antoine Assi
fee2724a0e Merge pull request #3989 from Spinnich/feat/screenscraper-quota-awareness
feat(screenscraper): pace and report scans against the account's reported limits
2026-07-30 17:52:10 -04:00
Georges-Antoine Assi
f8bbb8af18 chore(screenscraper): tighten the quota wording and comments
Name the reset timezone by its shortcode, and drop comments that either
restate the code or explain a change rather than the behaviour.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 17:43:37 -04:00
Georges-Antoine Assi
a55d50998e refactor(screenscraper): move the scan reporting into ss_handler
Priming the account, the quota lines and the end-of-scan skip list are
ScreenScraper's own bookkeeping, so they move out of the scan socket and
behind begin_scan(), log_quota() and log_scan_summary(). The scan keeps
only the decision it owns: whether this scan uses ScreenScraper at all.

The quota-line bookkeeping joins the skipped ROMs in a _ScanState
instance, so the tracking that resets together lives together and needs
no global statement.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 17:43:32 -04:00
Georges-Antoine Assi
7168f5895c refactor(screenscraper): bundle the per-scan state in one object
The account limits, the two one-shot advisory flags and the daily-quota
breaker all reset together at the start of a scan, so they now live
together in a _ScanState instance. Mutating its attributes needs no
global statement, and reset() walks the dataclass fields so a new one
cannot be left out.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 17:29:56 -04:00
Georges-Antoine Assi
7ce4f1d255 Merge pull request #4005 from Spinnich/fix/missing-tab-sidecar-perf
perf(roms): stop the Missing tab scanning the whole library
2026-07-30 15:06:59 -04:00
Georges-Antoine Assi
440cc6fa2d docs(roms): drop two redundant comments
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 14:58:42 -04:00
Georges-Antoine Assi
6fd2d9576c fix(backend): re-run the Hasheous hash lookup on a hashes scan
A ROM's "verified" state comes entirely from the Hasheous signature match
flags in `hasheous_metadata`, but `ScanType.HASHES` was missing from both
Hasheous gates in `scan_rom`. A rehash recomputed the file hashes and then
never re-asked Hasheous about them, so the verification chips stayed dark
(#4001). RetroAchievements was already gated in, which is why its provider
icon appeared while nothing lit up.

A follow-up update scan didn't help either: that branch is gated on
`rom.hasheous_id`, which is never set for a ROM that has yet to match.

Add `HASHES` to `fetch_hasheous_hash_match` and `fetch_hasheous_rom`, and
to the "don't overwrite existing base fields" branch: Hasheous now returns
a name/cover/summary on a rehash, and `_identify_rom` short-circuits before
the cover download, so a changed `url_cover` would point at an image that
is never fetched.

Fixes #4001

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 14:53:46 -04:00
Georges-Antoine Assi
1dd36cc58d feat(v2): previous / next game buttons on the details page
Restores the v1 gallery-stepping affordance in the v2 details view. A new
PrevNextNav composite reads the current ROM's position from the v2 gallery
store's ordered `romIdIndex`, so the order matches whatever gallery the user
came from (filters, sort, grouping included), and hides itself when the ROM
isn't part of a list (direct link, related-game jump, Home row).

Fixes #3998

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 14:53:42 -04:00
Spinnich
65a5aec5e0 fix(screenscraper): pace at the budget the account reports
ScreenScraper's FAQ gives the per-minute budget as `threads x 50`, while
`maxrequestspermin` came back as `1024 x (threads + 1)` on every account
measured. Reading the field as the unreliable one, pacing took the lower of
the two, pinning a 9-thread account to 450 requests per minute against a real
allowance of 10240.

ScreenScraper confirms the API was changed without the documentation
following it, and that the reported field is the authoritative one, so pace
at it and drop the formula.

That leaves no basis for a default rate either. Until the account reports,
the one-thread default is the guard: a single in-flight request cannot outrun
any budget ScreenScraper hands out, and priming reads the account before the
first ROM, so at most one request is ever unpaced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 16:26:41 +00:00
Georges-Antoine Assi
2c8009dc53 Merge pull request #4004 from rommapp/fix/sgdb-skip-dmca-locked-grids
Skip DMCA-locked grids when scraping SteamGridDB
2026-07-30 10:48:12 -04:00
Georges-Antoine Assi
2882f9711a Restore DMCA placeholder comment on the grid filter
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:41:55 -04:00
Georges-Antoine Assi
77925db009 Drop redundant DMCA placeholder comments
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:41:16 -04:00
Georges-Antoine Assi
ea677be6af Align cleanup task tests with unconditional cron string
The scheduled cleanup task now always carries the configured cron string,
so assert that instead of expecting None, and set the cron string to None
explicitly to exercise the unschedule branch in init().

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:38:56 -04:00
Spinnich
0526ded376 test(roms): drop the tautological index assertion
Asserting the model declares the index only restates `models/rom.py`. The
migration test covers what matters: the index exists in a database the
migrations built. Also pin the predicate test to the literal it compiles
to, so an unrelated `IS NOT NULL` elsewhere in the query cannot fail it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 14:24:21 +00:00
Georges-Antoine Assi
6217235c4e Skip DMCA-locked grids when scraping SteamGridDB
SteamGridDB does not remove assets taken down under DMCA; it returns them
with "lock": true and strips the URL signature, so the CDN serves a
placeholder image reading "This asset has been removed in response to a
DMCA takedown notice" for both the full asset and its thumbnail.

Filter locked grids in _get_game_covers, the single funnel for scan
matching, ID lookups and the manual cover picker.

Closes #4003

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:21:00 -04:00
Spinnich
fdb000576a perf(roms): stop the Missing tab scanning the whole library
Settings -> Library Management -> Missing made three whole-library passes
per request, two of which produced data the page never renders, and none
of which could be cached because "missing" counts as a filter.

- The tab now opts out of the char index, the filter values and the
  ordered id index, so the endpoint serves its total from a plain COUNT.
- `missing_from_fs` gets a composite index with `name_sort_key`, and the
  filter compiles to an equality: MariaDB does not treat `IS NOT FALSE`
  as indexable, so the index would otherwise only ever be scanned end to
  end. The column is NOT NULL, so both forms match the same rows.
- The filter-value list is keyed on the scope (search / platform /
  collection) alone. It is built from a query that never applies the
  row-level filters, so a filtered request now answers with, and warms,
  the same whole-library entry an unfiltered one does.

Fixes #3992

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 12:13:03 +00:00
Georges-Antoine Assi
426be64dc7 fix(security): close three permission gaps from the 5.1.0 audit
Restrict ROM file deletion to the ROMS/DELETE grant. The new
DELETE /roms/{rom_id}/files/{file_id} route gated on ROMS_WRITE alone and,
unlike its manual/soundtrack/screenshot siblings, carried no category guard,
so a group holding write-but-not-delete could remove game files from disk
while whole-ROM deletion still required ROMS/DELETE.

Gate mutating streaming routes on ROMS_USER_WRITE instead of ROMS_READ,
matching the play-session routes. ROMS_USER_WRITE is always-on for
authenticated users, but absent from READ_SCOPES, which is all KIOSK_MODE
grants an anonymous visitor. Kiosk visitors all share user_id=-1, so session
ownership could not separate them and any visitor could claim sessions and
overwrite another's save states.

Restore the ENABLE_SCHEDULED_CLEANUP_ORPHANED_RESOURCES gate on the cleanup
task's cron_string. It was dropped in 06cafd4b1, whose message refers to
update_switch_titledb, leaving the documented opt-out inert and scheduling a
destructive task nightly. That commit also broke two of the task's own tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-29 18:28:04 -04:00
Georges-Antoine Assi
06cafd4b10 fix cron_string in update_switch_titledb 5.1.0 2026-07-29 17:41:52 -04:00
Georges-Antoine Assi
443c796f1e reduce freegosy text 2026-07-29 16:55:22 -04:00
Spinnich
c7284f02d2 Merge remote-tracking branch 'upstream/master' into feat/screenscraper-quota-awareness
# Conflicts:
#	backend/endpoints/sockets/scan.py
2026-07-29 14:01:06 +00:00
Spinnich
c2786429fd fix(screenscraper): address review feedback on quota awareness
Four points from the PR review:

- Leave the process-global ScreenScraper state alone when a scan does not use
  ScreenScraper. DEV_MODE runs scans in-process, so overlapping scans could
  otherwise clear each other's learned limits and skipped ROMs.
- Return pacing to the defaults when the per-scan state resets. Priming re-reads
  the account moments later; should that fail, the conservative default is safe
  for whatever account the credentials now name, whereas the previous scan's
  allowance may be more than this one is entitled to.
- Stop a rate-limited ROM from trying the next lookup. A refusal that survives
  the retry now propagates out of the handler and is caught once per ROM in
  fetch_ss_rom, instead of being swallowed per call site and sending the caller
  on to spend another retried request against a budget that is already gone.
  _is_daily_quota_error excludes the rate-limit 429 so the two stay distinct.
- Hand the request slot back before inspecting and re-encoding a cover, so
  local image work no longer holds a ScreenScraper thread.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-29 13:55:19 +00:00
Georges-Antoine Assi
ff8d4d0d5d Merge pull request #3986 from rommapp/fix/launchbox-cloud-empty-store
fix(launchbox): stop the cloud provider from silently matching nothing
2026-07-28 23:09:10 -04:00
Georges-Antoine Assi
57f4fd21d0 cleanup 2026-07-28 23:01:07 -04:00
Georges-Antoine Assi
49f2b48f5f Merge pull request #3987 from rommapp/fix/gallery-placeholder-row-overflow
fix(gallery): pack placeholder covers at the active boxart ratio
2026-07-28 22:57:39 -04:00
Georges-Antoine Assi
e8aa2f5afd fix(gallery): pack placeholder covers at the active boxart ratio
The grid flow-packs rows in JS from each card's real width
(cardHeight * coverRatio), and rows render nowrap with flex-shrink: 0 —
so an underestimated width overflows the viewport instead of wrapping.
Ratios are measured on cover load, but a rom with no cover paints its
placeholder at the boxart style's ratio and never measures, so the
packer's hardcoded 2/3 under-reserved its width and let an extra card
into the row.

The packer now takes the style ratio as its fallback for any position
without a measured cover, which also covers the pre-load paint of every
card in a non-2/3 gallery.

Fixes #3984

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 22:36:39 -04:00
Georges-Antoine Assi
ad07bafbd1 fix(tasks): load the task list when the tasks page opens
The list was fetched once at app boot, inside a bootstrap that runs
before anyone is logged in. /tasks needs the tasks.run scope, so any
session established after boot (any login without a reload) left the
watcher, scheduled and manual lists empty for the rest of the page load,
in both UIs. For a logged-in non-admin the same call 403'd on every page
load and tripped the interceptor's redirect to login.

Fetch on mount from the pages that need it instead.

Fixes #3981

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 22:22:13 -04:00
Georges-Antoine Assi
8c12ac86a1 fix(launchbox): keep the heartbeat honest during a first import
The store is written in batches, so an initial import answers for the
names committed so far long before it holds the whole dump. Checking
that the name index exists reported the provider healthy off a fraction
of the entries, and a run that died partway left it that way for good.

Flag the initial import and clear it once a run completes, so only a
finished import counts as healthy. A refresh keeps serving the previous
dump, so it is not flagged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 22:22:06 -04:00
Georges-Antoine Assi
963e4cab48 Merge pull request #3983 from rommapp/fix/valkey-snapshot-write-amplification
fix(docker): stop valkey rewriting its whole RDB every few minutes
2026-07-28 22:02:39 -04:00
Spinnich
e1225c8a9c fix(screenscraper): don't repeat an unchanged quota line
The last platform's quota readout and the end-of-scan summary both call
_log_ss_quota, so a completed scan printed the same numbers twice in a row.
Skip a line identical to the previous one, resetting at the start of each scan
so a new run always reports.
2026-07-29 01:30:18 +00:00
Georges-Antoine Assi
f4984fb218 cleanup 2026-07-28 21:28:09 -04:00
Georges-Antoine Assi
7f0636aed5 Apply suggestion from @greptile-apps[bot]
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-07-28 21:26:15 -04:00
Georges-Antoine Assi
79a64c473e Merge pull request #3982 from rommapp/fix/platforms-index-hide-empty
fix(platforms): hide empty platforms behind a toolbar filter
2026-07-28 21:06:13 -04:00
Georges-Antoine Assi
85351739e8 fix(platforms): use a clearer icon for the include-empty filter
mdi-select-all is a marquee-selection glyph, so it read as an action
rather than a filter state. mdi-asterisk carries the wildcard
"everything" meaning the segment actually has.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 20:11:09 -04:00
Georges-Antoine Assi
52940ea3d4 fix(launchbox): stop the cloud provider from silently matching nothing
LaunchBox cloud lookups read from a Redis store that only the metadata
update task fills, but nothing surfaced when that store was empty. The
provider reported healthy, every search returned zero results, and the
logs said nothing.

- heartbeat now reports unhealthy until the store is populated, and an
  empty store logs what to set to fix it
- the update task can be run manually whenever LAUNCHBOX_API_ENABLED is
  on, instead of also requiring the scheduled-update flag
- the ~600k entry dump was buffered into a single pipeline, peaking at
  1.7GB of RSS and writing nothing at all if the job was killed part way
  through. Writes now go out in batches and parsed elements are dropped
  as they are consumed, which caps the run at ~260MB. The task also gets
  its own timeout, since the default 5 minutes does not cover a 100MB
  download plus a 500MB parse
- alternate name lookups ignored the platform, so "Super Mario World" on
  PlayStation matched Super Mario Bros.
- Coleco ADAM was spelled wrong, and Famicom / Super Famicom pointed at
  platform names LaunchBox does not use

Fixes #3981

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 19:55:16 -04:00
Georges-Antoine Assi
ae46dc64c2 fix(tasks): make the upload tmp cleanup importable by the RQ worker
Importing the task module first, as the worker does when it resolves the job,
pulled endpoints.roms in and closed an import cycle through decorators.database.
RQ hides the ImportError behind "Invalid attribute name: run", so the cleanup
never ran and orphaned chunked-upload directories piled up.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 18:41:51 -04:00
Georges-Antoine Assi
48259b3a9e fix(docker): snapshot the internal valkey hourly instead of every few minutes
The keyspace holds the Switch TitleDB and LaunchBox caches, so dump.rdb runs
to hundreds of MB (424MB on a dev instance). Valkey's stock save policy
rewrites all of it every ~5 minutes once 100 keys change, which idle RQ
bookkeeping alone triggers, for gigabytes of disk writes per hour.

Fixes #3980

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 18:41:49 -04:00
Georges-Antoine Assi
8abd192163 fix(v2): batch URL query writes so concurrent toolbar filters don't stomp
`router.replace` is async, so `route.query` keeps reading the pre-navigation
value. Two URL-backed controls changing in the same flush each built their
next query from that stale snapshot, and the second navigation won with a
query that never saw the first one's key.

Reachable today on the Collections index: picking the "virtual" kind also
clears the visibility filter in the same flush, and the clear dropped
`?kind=virtual`.

Route every writer (search, view mode, Platforms and Collections filters)
through `patchQuery`, which merges patches and issues one navigation per
tick.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 18:41:15 -04:00
Georges-Antoine Assi
ba83af5caf fix(platforms): hide empty platforms behind a toolbar filter
The Platforms index switched to allPlatforms, so every leftover 0-game
platform row rendered in the grid, burying real libraries under hundreds
of stubs.

Empty platforms are hidden again by default and surface through a new
segmented toolbar cluster, URL-synced as ?show=all. They stay reachable
(and deletable) that way, so they don't become stranded in the database
again.

Fixes #3979

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 18:32:44 -04:00
Georges-Antoine Assi
81d740c5bd Merge pull request #3976 from rommapp/fix/rom-artwork-nested-game-media
fix(frontend): only treat top-level game folder files as media assets
2026-07-28 18:20:11 -04:00
Georges-Antoine Assi
345610afad Merge pull request #3974 from XenuIsWatching/fix/scan-concurrency-and-stop
fix(scan): refuse concurrent scans and stop queued ones
2026-07-28 18:19:48 -04:00
Georges-Antoine Assi
ead93451a1 Merge pull request #3973 from seffignoz/fix/v2-emulatorjs-full-navigation
fix(v2): use full document navigation for EmulatorJS player
2026-07-28 18:01:24 -04:00
Georges-Antoine Assi
fecd5b7c75 Merge pull request #3972 from XenuIsWatching/perf/orphaned-cleanup-scandir
perf(tasks): walk resource directories with os.scandir
2026-07-28 18:00:51 -04:00