A slot-less POST /api/saves behaves as a filename upsert, and two
details combined into silent save corruption.
1. get_save_by_filename only filtered by slot when one was passed, so a
slot-less lookup could match (and overwrite) a save row living in a
named slot. Scope slot=None to the null-slot save (Save.slot IS NULL)
so a slot-less upload can never adopt a row from another slot.
get_save_by_content_hash keeps its documented cross-slot slot=None
behavior (dedup-only, non-destructive).
2. The upsert branch only wrote file_size_bytes and content_hash while
the bytes landed under a path derived from the request's emulator, so
the row's hash could disagree with the file it still pointed at. Also
persist file_path/emulator, and remove the now-orphaned file when the
row's location changes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bulk_mark_present issued an unconditional UPDATE setting missing_from_fs=False
on every matched row, including rows already present. Since Rom.updated_at has
onupdate=utc_now, every scan re-stamped all skipped/unchanged ROMs of a
platform, defeating updated_after-based incremental consumers and busting every
cover URL (?ts={updated_at}) on each scan.
Mirror the missing-side guard (mark_missing_roms) by restricting the UPDATE to
rows that actually flip via Rom.missing_from_fs.is_(True), so an unchanged
platform issues no updates.
Fixes#3836
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move the getOpenRooms and io-wrap overrides to the top of EJS_onGameStart so
they are installed synchronously, before room polling or a Create/Join action
can start, rather than at the tail of the callback.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The setup wizard's metadata step showed "API key invalid" for any
enabled provider that failed its heartbeat probe, including flag-only
providers like PlayMatch and Hasheous that have no API key. This
contradicted the Settings > Metadata sources view, which already adapts
its wording per provider.
Mirror that behavior: add a `requiresKey` flag to each source and use
connection-oriented wording for flag-only providers ("Unreachable" on a
failed probe, "Provider disabled" when off) instead of key-oriented
wording. Reuses existing locale keys, so no new translations are needed.
Fixes#3795
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The v2 gallery refetch watcher in GalleryShell only watched the filter
selection arrays, not the per-filter logic operators (any/all/none).
Toggling a filter to the inverse ("none") updated the store but did not
trigger a refetch, so the results only changed when the selection itself
was edited or after a reload (URL hydration re-runs the initial fetch).
Watch all *Logic operators alongside their selections so inverting a
filter (e.g. statuses -> "none") refetches immediately.
Fixes#3798
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>
RomM's netplay overrides targeted an outdated EmulatorJS API, so on the
nightly build they were dead code and the emulator's own URL logic ran.
That built the room-list request from `netplay.url` (the page host with no
scheme), which resolved relative to the SPA route and duplicated the domain
inside the path. nginx's SPA fallback then answered with index.html, so the
room list was always empty. The socket also used the default socket.io path
instead of RomM's mounted /netplay/socket.io.
- Set EJS_netplayServer to window.location.origin (scheme included).
- Override netplay.getOpenRooms on the current netplay instance to hit
/api/netplay/list with a root-relative path.
- Wrap the EmulatorJS-bundled global io to inject the /netplay/socket.io path.
Fixes#3799
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Only auto-bind a default save as the "Save & Quit" write-back target when
the choice is unambiguous (a single save, or no compatible state armed).
With multiple saves and a state armed, loading the state injects a
different SRAM timeline, so binding an arbitrary user_saves[0] let
Save & Quit PUT over a named slot the user never selected. In that case
leave the save unbound and require an explicit slot pick.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds tools/benchmark_generated_metadata.py, which times the representative
roms_metadata read workload (rating/date sorts, player-count filter) and,
by default, flips between revision 0097 (derive-on-read view) and head
(generated columns) to print a before/after speedup table against the
same data.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The STORED generated columns backing roms_metadata used a terse rm_
prefix. Rename them to an explicit generated_ prefix (generated_genres,
generated_average_rating, etc.) and update the alembic autogenerate
filter in env.py to match.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The g-prefix sequences and the / search shortcut listened during play,
so pressing common game keys (g then h/p/c, or /) navigated away and
killed the session. Gate the handler on the playing store flag.
EmulatorJS set the flag on play but never cleared it on unmount, leaving
pad and hotkey navigation dead after exiting a game. Ruffle never set it
at all, so Flash sessions had no protection. Both players now flag the
session on play and release it on unmount.
useGamepad gates its pad-to-UI translation on the playing store flag, but
the v2 Stream player never set it, so button presses kept navigating the
app (and a Back/Start press could tear the session down mid-game). Flag
the session while launching or playing and clear it on unmount.
A self-hosted PLAYMATCH_API_URL on a LAN IP, localhost, or a Docker
service name is rejected by the shared HTTP client's SSRF defense before
connecting, so health checks and lookups fail. Add a narrowly scoped
allowlist, derived from the admin-configured provider URL, that both SSRF
gates (the static URL hook and the connect-time backend) honor. The
exception is matched by exact host and port, and the public default URL
is unaffected since public addresses already pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
failed_items was just the length of failed_ids. Remove the redundant
counter from the delete endpoints (roms + firmware) and the response
type; callers that need the count derive it from failed_ids.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Decouple save-file and savestate selection in the v2 player so they are no
longer mutually exclusive. When a compatible savestate exists, the config
screen still opens on the States tab, but the origin save now stays bound
instead of being nulled. This keeps "Save & Quit" updating that save file in
place (PUT) rather than spawning a new slot-less save (POST) that named-slot
sync clients never see.
Surface the save slot as a chip wherever a save renders (config-screen list,
resume preview, and the in-game save picker), guarded so states and slot-less
web saves show nothing. Adds the `play.slot` key across all locales and wires
`slot` into the story fixtures.
v1 (frozen) is left untouched; the change is v2-only.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The delete handler re-read the dialog refs (roms, platform, exclude flag)
after the request resolved. Because the dialog is a singleton, a fresh
showDeleteRomDialog event arriving mid-request could swap those refs, so
the completed request would prune the new dialog's IDs instead of the
ones it processed. Snapshot the state at entry and act on the snapshot.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The bulk delete endpoint deletes per-ROM and can partially fail, but the
v2 dialog pruned every requested ROM from the selection and gallery. A
ROM that failed to delete stayed in the library yet lost its selected
state, so the user couldn't retry the failed subset.
Return the failed IDs from the delete endpoints (roms + firmware, both
via BulkOperationResponse) and, on the client, only prune the ROMs that
were actually removed. Failed ROMs stay selected and visible for retry;
the single-ROM route only navigates away when its ROM was deleted.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The v2 delete flow cleared only the legacy v1 selection store
(romsStore.resetSelection()), leaving the v2 gallerySelection store
untouched. Since v2 multiselect and the SelectionBar read from
gallerySelection, the deleted ROMs stayed selected: the bar remained
open with stale rows and re-running a bulk action 404'd.
Drop the deleted IDs from gallerySelection via removeIds so a full
delete closes the bar while a partial delete keeps the rest selected.
Fixes#3822
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>