The periodic save upload only ran on EmulatorJS' "System Save interval"
tick (5 minutes by default, never when the player disabled it), and was
off unless emulatorjs.auto_save_sync was set. The player now flushes the
SRAM itself every 5 seconds while the game runs, so the existing tracker
sees a new in-game save on the next two agreeing ticks and uploads it,
and the config flag defaults to on.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MozJiij1oQbu12GvtAPBFR
* Treat every disc descriptor as a disc, not just .cue
playlist_files keyed on .cue alone, so a Dreamcast .gdi set, a CloneCD
.ccd set and an Alcohol .mds set all fell through to "every file is a
disc" -- the descriptor and the raw tracks it cannot boot without were
listed side by side.
The three readers of the rule each got that wrong in their own way: the
playlist shipped inside the download zip named non-bootable tracks, and
the in-browser disc swapper offered them as discs.
Key on a set of descriptor extensions instead, so no one sheet format is
privileged over the others. The shape is unchanged -- descriptors if any,
else everything -- and so is the download zip, which lists every file
regardless.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Keep a disc that stands on its own beside a descriptor
Selecting descriptors and discarding everything else assumed a multi-file
ROM is all one format. It is not: a .chd sitting beside a .gdi boots on
its own, and returning only the .gdi dropped it from the playlist and
from the swapper's targets.
Exclude the raw tracks a sheet points at instead of keeping only sheets.
The tracks are still not discs, so every case the previous commit fixed
stays fixed, and a disc no sheet describes now survives.
This also settles the same bug on the .cue path, which predates this
branch: disc1.cue + disc1.bin + disc2.chd used to list the cue alone.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Count a sheet's audio tracks as tracks
A .cue names its CDDA tracks the same way it names its data track, so a
.wav or .flac beside one is data, not a disc. The playlist listed them.
Brings the list in step with the shell's own in src/main/discs/m3u.ts,
which has carried the audio formats since it was written.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
A folder the scanner maps to a media category now refuses files that
category cannot hold inside resolve_upload_destination, so the chunked
flow the v2 tabs use gets the same allowlist the media routes had, and
those routes drop their own copies. commit_upload records an upload
provenance for walkthrough files that arrive without one and returns the
registered row, which the walkthrough route uses for author and title.
The refresh lock moves to Redis so uploads landing on different gunicorn
workers cannot drop each other rows. An empty body filename is rejected
instead of falling back to the header.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`has_live_worker` asks RQ for the worker count and the suspension flag,
two constant-cost reads, instead of hydrating every registered worker.
The cleanup stats serialize through `dataclasses.asdict`, so a new
counter is declared in two places rather than three. The task endpoint
test takes the shared task fixture, the legacy-stats shim says when it
can go, and the two Settings specs share one axios-error helper under
`src/test-utils` while the games spec starts from a non-empty list.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9ta8rXUTP9aMdatPYKX4K
A name the folder already has is refused by /roms/upload/start with a 409,
and the tabs used to surface that as a plain error. useRomFileUpload now
collects the refused files, asks once in a danger-toned confirm dialog and
retries them with the new optional overwrite body field, which lets the
chunked flow replace the file instead of claiming the name exclusively. A
declined file is dropped without a toast. The strings ship in all locales.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Follow-up to #4548 from the code-review pass. Stats a 5.2.0 release
stored under `platform_id` are widened to `platform_ids` when a job is
reported, so listing old finished cleanups validates again. The live
worker check moves next to the queues as `has_live_worker`, with its
own tests, and the endpoint names the queue it enqueues on so the check
and the enqueue cannot drift apart. The cleanup tasks return the typed
stats the response schemas declare. The developer setup points the RQ
commands at the backend's own Redis settings through `-c config`, and
the architecture doc mentions the 503.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9ta8rXUTP9aMdatPYKX4K
The Files tab streamed chunks through /roms/upload/* and registered the
result with the scanner listing, while each Media route (soundtracks,
screenshots, manual files, walkthrough files) carried its own copy of the
sanitize, promote, mkdir, stream, stat and DB upsert sequence. Those copies
crashed with FileNotFoundError on a file name outside Latin-1: the browser
sends the header as Latin-1 and the multipart field name as UTF-8, so the
parser target registered under the header name never received the part
and os.stat failed after the folder had been created.
handler/rom_upload.py now owns the shared ingestion (resolve and prepare
the destination, stage next to the target, move into place, refresh the
ROM's file rows through the scanner) and both the chunked completion and a
new receive_rom_file sit on it. The media routes only check the extension
and delegate; a body naming the part differently is a 400. /start gains an
optional body filename that wins over the header, so names outside Latin-1
arrive intact, and rom_id becomes optional in that body.
On the v2 frontend a single useRomFileUpload composable wraps the chunked
upload, the single-file conversion prompt, the toasts and the refetch; the
Files tab, Soundtrack panel, Screenshots subtab, Walkthrough subtab and the
manual "add to ROM folder" target all call it with their folder. The
service sends the real name in the body and a percent-encoded one in the
header. The v2-only uploadScreenshots/uploadWalkthroughFiles service
functions and the soundtrack-only toasts are gone. Media subtabs now
refuse an existing file name (409) like the Files tab, instead of
overwriting it silently.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X1FgnCzXjM3rzkxggi7g6C
The worker guard now ignores workers that announced their death or are
suspended, and the tests run with a live worker on the task queue by
default, so the other successful-run tests pass again; a scan-only,
dead or suspended worker is checked to be refused. The developer setup
runs each worker in its own terminal, adds the RQ cron process that
registers the schedule, and ties the Redis URL to the `.env` defaults.
The Japanese, Korean and Chinese cleanup messages use their own
punctuation, and both Settings sections have a test that the server's
reason reaches the error snackbar.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9ta8rXUTP9aMdatPYKX4K
`GET /tasks/status` failed response validation once a missing-ROMs
cleanup had run: the task reports `platform_ids` while the schema
still declared `platform_id`, and the missing-firmware cleanup had no
schema at all. Both shapes are declared now, the generated types follow,
and the task-by-id test checks a finished job of each kind.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9ta8rXUTP9aMdatPYKX4K
A task run with no RQ worker sat queued forever while the UI reported
it queued and later refreshed as if it had run. The endpoint now
answers 503 with the reason, the Settings sections show that reason
instead of the axios wrapper, and the developer setup documents how to
start the workers. The delete-ROM dialog's filesystem warning gets its
bottom padding above the footer, and the cleanup-queued message loses
its em dash in every locale.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The save and state delete endpoints carried the same row, file and
screenshot removal sequence inline. `remove_asset_file` and
`remove_screenshot` now live in the asset store, and each endpoint
keeps a one-line `_delete_save` / `_delete_state` over them.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A retried upload whose bytes already sit in the slot returned before the
retention pass, so a slot above a newly lowered cap stayed that way
until a different file arrived. The cap now applies on that path as
well.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Slot pruning is one locked handler query that selects only the tail of
the slot by column, so an upload no longer loads every joined version;
the retention tests share their seeding helpers. Both asset lists fold
their groups through one useGroupFold composable, render the owner chip
through one AssetOwnerChip, and AssetStrip tracks each group's newest
timestamp while it builds the group. The two upload dialogs share a
PendingFilesDropzone for the drop zone and file list. The slot title
and the newest-by-timestamp lookup live in the utils next to their
siblings. The split states layout aligns its label and content rows
with a subgrid instead of hand-matched heights, so AssetPreview loses
the consumer-driven eyebrow height. Stories take explicit ids.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Named slots kept every version, so a slot written once per session grew
without bound. `MAX_SAVES_PER_SLOT` (default 50, 0 disables) now caps
every slotted upload: after a new version lands, the slot is pruned to
the tighter of the server cap and the client's autocleanup limit, files
and screenshots included. Slot-less archives are never touched.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The Playmatch switch shipped its choice as a standalone `playmatch_enabled`
flag, but the backend gates the lookup on `MetadataSource.PLAYMATCH in apis`
and nothing ever read the flag, so UI-initiated scans never queried
Playmatch. Push `playmatch` into `apis` like `hasheous`, and drop the dead
flag from the payload and the scan plumbing.
Fixes#4505
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Writes that start while a save load is in flight are dropped, since the
bytes they read predate the load, and forced writes capture the write
generation before waiting on the queue so a load that lands meanwhile
voids them. The tracker clears its boot baseline after the first upload
so a return to those bytes still syncs, and a forced write is skipped
only when the SRAM matches a slotted save loaded from the server, so a
slot-less legacy save still reaches the slot on an unchanged Save &
Quit. Autocleanup removes an evicted save's screenshot row and file
through the same helper the delete endpoint uses. The launch screen's
save list grows with the page outside viewport-fit mode instead of
nesting a second scrollbar.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XXrMndq8eYexafm6nhajLo
The save tracker now keeps a baseline separate from the bytes the server
holds: SRAM restored by a state or a fresh boot makes the periodic tick
wait for a change, but a forced write still opens the slot version since
nothing was uploaded yet. Forced writes skip only when no version exists
and the SRAM still matches the loaded save. A slotted upload names the
screenshot after the tagged save whatever the client called it, so
Save.screenshot matches by stem. Slot select values are namespaced so
the "new slot" entry cannot collide with a user-named slot, the info and
clear buttons get a 44px hit area, and the asset wrapper only scrolls in
viewport-fit mode.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XXrMndq8eYexafm6nhajLo
Seed the save tracker once per boot and from the bytes just loaded
instead of re-reading the SRAM, fold the "wait for the queue, skip
unchanged bytes" sequence into one helper used by both forced writes,
and upload the state and the save in parallel on Save & Quit. The
loaded save is a plain variable, the slot fallback lives in one place,
the selection id derives from the selected asset, and the byte compare
is a plain loop.
The viewport-fit layout drives AssetList's own scrollable prop from the
lg-and-up and tall breakpoints instead of a CSS custom property, and
the fit selectors drop the redundant root modifier. The slot length is
validated by the upload endpoint from a limit on the model, and the
datetime tag helper takes its timestamp explicitly.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XXrMndq8eYexafm6nhajLo
Save writes from the periodic tick, the in-game Save button and Save &
Quit now run through one chain, so two first writes cannot both open a
version; loading a save bumps a generation that voids in-flight writes,
and byte-identical uploads are skipped since a slotted upload bypasses
the backend dedupe. Slotted uploads let the backend stamp the timestamp
and tag the screenshot with the same one, so save and screenshot match
by stem again, and a session version opened without a screenshot can
still receive one on update.
A slot-less save is no longer kept as a write target when a state is
armed, slot names are compared exactly like the backend does, the custom
slot field is capped at the column length, and an empty-string slot no
longer collides with the "new slot" sentinel. The viewport-fit layout
uses a new `tall` breakpoint token gated on `lg-and-up`, gives the hero
column a scroll fallback, and lets AssetList keep its own scroll cap via
a custom property. The slot info icon becomes a tappable button so the
tooltip also opens on touch.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XXrMndq8eYexafm6nhajLo
The test shrinks the claim refresh and staleness windows to 0.05s and 0.2s and
races them against a 0.5s activate, so whether the refresh lands before the
read depends on scheduling. It passed and failed in alternating runs on an
unchanged tree.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
simplify pass over the save-picker change.
The claim validated the pick, dropped the resolved row and passed the bare id
down two layers, where hydration fetched and re-checked the same save. It now
carries the row the way the resume state and the memory card already are, so
the restorability rule has one home and the claim one lookup.
The picker holds the picked id rather than the row, so an id that is no longer
on offer falls back to the newest by construction instead of through a watch,
and the list of archives uses AssetList, the variant meant for saves, rather
than the tile strip whose thumbnail area a save never fills.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
code-review pass over the save-picker change.
The launch screen listed every save this emulator wrote, but the broker only
restores .zip archives, so a bare save file could be named as the one about to
be restored while a much older archive actually went up. One restorable list
now feeds the panel, the tab and the picker alike.
A claim that carries a pick looks the save up by id instead of loading every
save on the ROM to scan for it, and the emulator comparison normalizes both
sides so a config value that is not already lowercase cannot silently match
nothing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Trigger names are schema-wide, so the fixed probe name could name an
operator's own trigger, and DROP TRIGGER IF EXISTS would really remove it.
A fresh uuid per call makes the statement a guaranteed no-op, so the only
error it can raise is the refusal it is looking for.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The magic-byte test moves behind `_is_png`, so the two places that need it (the
broker body, where the answer decides whether the embedded frame is tried, and
the filesystem sink) read as one rule instead of two. Narrowing the extract
catch back to the failures a savestate archive can raise keeps a programming
error loud rather than logging it as a missing thumbnail.
The frame fetch gets its own 10s deadline: it runs while the claim is still
held and the player waits on the exit screen, and a thumbnail does not need the
archive-transfer budget.
From the pr-ready simplify pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The broker's screenshot now shadows the frame PCSX2 embeds in its own state,
so a 200 that is not a PNG has to read as no frame rather than as an unusable
one, or the state lands with no thumbnail at all. Extraction moves onto a
thread alongside the fetch it falls back from, since the body it inflates runs
to hundreds of megabytes.
From the pr-ready code-review pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The member picker reused patcher.select-file, so a ROM with several base
files rendered two dropdowns both labelled "Select file". Add
patcher.select-archive-member across all 18 locales and use it.
Treat an empty archive_member_name form field as "not specified" rather
than as a member name that matches nothing.
Fold getZipMembers into the archiveMembers computed and watch that, so
the selection also resets when the member list itself changes.
Add PatcherTab coverage for sending the selected member, typed against
RomArchiveMember so the fixture cannot drift from the schema.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A module-level exception tuple freezes zipfile.BadZipFile, but seven test
modules reload the zipfile module, which rebinds the class. After any of
them runs, a corrupt archive escaped the handler and surfaced as a raw
BadZipFile instead of a 400. Look the class up at raise time instead.
NotImplementedError goes with it, being a RuntimeError subclass.
Declare each rebuilt entry's final size instead of passing force_zip64,
so zipfile marks an entry ZIP64 only when it needs to; a patched ROM
handed to a basic unzip implementation was otherwise rejected even though
the unpatched archive loaded fine.
Drop the extracted and patched intermediates once they are consumed,
rather than holding three full-size copies for the life of the download.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- `rebuild_generated_columns` owns the index drop, since it is the one
place a column is dropped, so 0123's downgrade gets it too.
- `ensure_roms_columns` builds its action list first and runs on it, and
no longer re-reflects the table to re-test a column it just added.
- One list behind `STEAM_FED_COLUMNS`, and `INHERITED_COLUMNS` says what
the set difference at the use site used to.
- 0112 builds the view through `roms_metadata_view_sql`, and 0126 drops
the add-column branch the shared copy made unreachable.
- Tests share one generated-expression helper and read index and column
names off the module that owns them.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- `drop_roms_columns` drops a composite index that still spans a column
it removes before the ALTER: MariaDB and MySQL would otherwise keep the
index over the remaining columns, so 0126's unique index left by a run
that died before its stamp would become UNIQUE (platform_id).
- `ensure_roms_columns` recreates `roms_metadata` whenever it is absent,
so a run that died between its ALTER and the CREATE VIEW gets the view
back on the replay instead of only when a rebuild is pending.
- A generated column the engine does not reflect as computed counts as
not reading Steam and is rebuilt, rather than raising a KeyError.
- One home for the `steam_metadata` column name, imported by 0123.
- Tests pin the lost view, the leftover MariaDB default and the surviving
unique index; the ALTER recorder matches `roms` as a whole word.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
simplify pass over the save-picker change.
`resolve_save_archive` loaded every save the user has for the ROM just to find
one row by id. `db_save_handler.get_save` is the owner-scoped point lookup the
save endpoints already use for exactly this, so call it and check the rom_id,
which drops a list load per claim that carries a pick.
The ROM scoping moves from the query into the check, so pin it with a test.