mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
master
25 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2bc4b8d0e5 |
fix(sync): support safe RetroArch WebDAV backups (#5648)
* fix(sync): preserve RetroArch saves before WebDAV overwrites * fix(sync): lock RetroArch backups across workers and honor zero retention Address Greptile review on #5648: publish backups under an flock on the backup folder so workers cannot prune each other's copies, replace the os.link publish with an exists check and os.replace under that lock (no hardlink support needed), and skip pruning when MAX_SAVES_PER_SLOT is 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sync): harden RetroArch COPY backups (code-review) pr-ready step 2. Lock through a regular file so NFS grants the flock, answer 404 for PSP bundle paths so RetroArch still uploads, back up the state the upload overwrites rather than a served stream capture, compare the Destination authority without default ports, accept a lowercase Overwrite value, prune backups by age, and share the stamp regex. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(sync): simplify RetroArch COPY backups (simplify) pr-ready step 3. Check the source once before copying, publish backups with the served file mode, drop the redundant deleted/ segment from the backup storage path, and fold the two retention tests into one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sync): back up RetroArch deletes and share upload targets Back up the file a MOVE into deleted/ drops before dropping it, and read only the Destination tail so a reverse proxy may rewrite the host and prefix. COPY resolves its source first, answering 404 whenever an upload writes over nothing (versioned saves, PSP members), from the same upload target helpers PUT uses. Backups are hardlinked when the filesystem allows, and the stamp grammar and retention policy move to the sync handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(sync): list the RetroArch COPY route with the other WebDAV verbs COPY authenticates through _authorize like the rest of the WebDAV routes, so the route guard test lists it as handled in its module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8a1e6280b1 |
feat(saves): add save channels and snapshots (#5198)
* feat(saves): add save channels and snapshots * feat(saves): close spec gaps in save channels and hash with sigil * feat(saves): play snapshots in the v2 player, which pushes snapshots * fix(saves): code review: authorization, retention losses, held-save sync, batched responses * refactor(saves): simplify pass * refactor(saves): review-polish pass * docs(saves): humanizer pass * feat(saves): run every EmulatorJS page on the v2 player * feat(saves): per-user snapshot pins * feat(sigil): store the identity a save restore needs and pin sigil 0f05f25 * fix(saves): meet type-aware lint in the v2 player * feat(sigil): store N64 header and playlist title ids, pin sigil 0847fda * feat(saves): convert saves for a core on download and list save layouts * feat(saves): prune unreachable archival snapshots and empty detached channels on delete * feat(saves): device sync from the token, held snapshots and shared-card pushes * feat(saves): arc restores past abandoned snapshots and color channels by age * fix(saves): code-review and security-audit fixes * refactor(saves): simplify pass * chore(saves): review-polish pass * docs(saves): humanizer pass * fix(sync): file RetroArch autosave versions as their channel's next snapshot * fix(saves): address review findings and trim docstrings * fix(saves): share-lock planned rows by id so PostgreSQL accepts the lock * test(saves): stub the detached-channels fetch in SaveDataTab stories * feat(saves): carry the full current snapshot in a 409, pin sigil 2071dff * chore(sigil): pin 5d4ddb4, which reads .cue and .gdi sheets * docs(saves): drop v2 wording now that one UI remains * chore(sigil): pin 0190443, which reads PS2 raw BIN images and cue sheets * fix(sigil): treat a file too short for its format as routine during scans * chore(migrations): renumber save channel migrations after upstream's 0154 * fix(snapshots): a hardcore switch on unchanged content makes a new current * fix(sync): decide a channel's slot from its history and the device's snapshot * chore(docker): pin sigil at 794d99f for PSP Store release save prefixes * refactor(db): squash the save channel migrations into 0161 Fold the slot linking (0162) and the rom_files sigil identity columns (0163) into 0161_save_channels, so the feature ships as one revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(saves): close visibility and input gaps found in review (pr-ready step 2) code-review --fix: - negotiate_sync drops channel slots on ROMs hidden from the caller - channel PATCH/attach/DELETE answer 404 when the channel's ROM is hidden - a push copying a save from a hidden ROM answers 404 - _own_device applies require_token_device to bound client tokens - adopting a legacy save syncs its sharing with the channel it joins security-audit follow-ups: - another user's detached public save or state is no longer downloadable - profile and option values must be a single path segment - companions are de-duplicated and capped at 8 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(saves): share channel and asset lookups, drop duplicates (pr-ready step 3) simplify: - readable_channel_or_404 and channels_on_files replace four copies of the channel 404 check and two copies of the file-fed channel listing - readable_rom_asset_or_404 serves both public save and state downloads - _own_device resolves through require_device; _clone_origin takes the source - reuse _unprocessable, DESCRIPTOR_EXTENSIONS, SAVE_SLOT_MAX_LENGTH, uniqueBy and uuidv7; neutral forms default their required pattern to the allowed one - RetroArch delete checks held rows in one query, a guarded upload lists the slot only without a channel head, and uploads are read off the event loop - snapshotSession builds push requests once; player comment cleanups Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(saves): trim two docstrings to two lines (pr-ready step 4) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(saves): answer held RetroArch paths with 423, mirror slot labels - RetroArch Cloud Sync answers 423 Locked for a PUT over a held unslotted save and for a DELETE where only held rows sit at the path, instead of 409 and 404 - channelLabelForSlot returns null for blank and state_ slots, as the backend's channel_label does, so the player files them under no channel either - document that sharing a channel lets every user read and push into it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(docker): pin sigil at 85f88a8 for Switch .nup containers * fix(snapshots): a save pushed in another shape or format makes a new current * refactor(saves): drop the always-true SAVE_SYNC.SNAPSHOTS heartbeat flag Nothing reads it, and the SAVE_SYNC block's presence already tells a client the server speaks the snapshot API. Also trim the rom detail channel field comments to one line each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(frontend): use uuidv7 for every client-generated id Drop the randomToken wrapper and the notification inbox's Math.random tab id, so uuidv7 is the one helper that works outside a secure context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(saves): trim redundant snapshot API surface, dead code and duplicate logic API: - Drop PUT /snapshots/{id}/devices/{device_id}; GET /snapshots/{id}?hold=true holds. - GET /snapshots is history only (channel_id required); GET /channels serves currents. - A snapshot carries channel_id instead of an embedded channel. - POST /saves/{id}/content takes the same query parameters as the GET, plus container_path. Backend: - Remove the archival write path, clone.py, DBStatesHandler.get_state, the sigil identity-hash path, unused relationships and composite snapshot indexes. - One held/frozen lookup, one bulk-delete guard, SQLAlchemy dialect upserts, and the shared reserve_version_name in the writer. - The writer takes a visibility filter and checks the channel and parent itself. - The restore handler picks per-game or merge; fewer wrapper types and tables. Frontend: - Channel delete uses the shared typed confirm; DeleteChannelDialog is gone. - Held offline pushes go through a per-channel SnapshotSession. - Remove the slot-based pending upload path. - The timeline shares the fan's badge logic. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * refactor(saves): release archival backups through module functions The saves and states handlers each built a private DBSnapshotsHandler to call release_backup and refresh_backup_digests, since they can't import the shared instance. Both only ever ran inside the caller's session, so they are now module functions taking it, like channel_for_slot. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * refactor(saves): share one deleted-assets handler instance The saves handler built its own DBDeletedAssetsHandler because it can't import the package's instance. The instance is now built in deleted_assets_handler.py and re-exported by the package, so both use it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0a643a3e8e |
fix(sync): resolve RetroArch save names to the core's platform (#5533)
* fix(sync): resolve RetroArch save names to the core's platform A RetroArch Cloud Sync path names a game by file name only, so a name shared across platforms (a PS1 and a Saturn "Road Rash (USA)") always resolved to the lowest-id ROM. Uploads landed on the wrong ROM and the manifest hid the other platform's saves. Map each RetroArch core folder to the platforms it runs and prefer a ROM on one of them, including one that only owns a file of that name. An unknown core, or none, keeps the previous id order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sync): build the RetroArch arcade core platforms from the arcade sets Addresses Greptile review on #5533: MAME and FBNeo left out the mame, mame-advmame, fbneo and fba platforms, so a same-named Neo Geo ROM could take over a MAME ROM's saves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sync): apply code-review fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(sync): apply simplify cleanups Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(sync): cover a manifest with one name under two cores (review-polish) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sync): one core map, per-disc state slots, PSP serials on PSP - Move the EmulatorJS platform-to-cores map to the backend and serve it on the heartbeat; RetroArch core platforms invert it plus a top-up for RetroArch-only cores. - Map fbneo to "FinalBurn Neo" and dosbox_pure to "DOSBox-pure", the library names the cores report to RetroArch. - Resolve states by file name like saves, with a slot per disc-named state, so a disc folder game's state follows its save. - Resolve PSP serial-map titles with PPSSPP's platforms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a688676de7 |
fix: enforce ROM visibility on assets, sync, collections, stats and scan events (#5498)
* fix(sync): cap play sessions on sync completion and require roms.user.write The completion endpoint fed an unbounded play_sessions list to the same ingest as POST /api/play-sessions, which allows 100 per batch and requires roms.user.write. Apply both rules before the session is completed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(config): reject empty platform binding and version values config.yml exits on load when a platforms or versions value is empty, so the API must not write one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(collections): require smart collection criteria to be a JSON object Any other JSON value was stored, then failed the response schema and broke the smart collection list for every user who could see the collection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(stats): require roms.read on /api/stats Anonymous callers were served counts over the whole library, including platforms and ROMs hidden from users. The UI only calls it after login. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(permissions): apply ROM visibility to filters, saves, play sessions and collection removal /api/roms/filters aggregated facet values over the whole library, GET /api/saves/{id} and GET /api/play-sessions returned the caller's own rows on hidden ROMs, and removing ROMs from a collection could drop members hidden from its owner. The facet visibility clauses move onto RomVisibilityFilter so stats and filters share them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(webhooks): keep non-admin webhooks off the admin's internal metadata origins The SSRF exception for a self-hosted Playmatch or Hasheous applied to every request, so a user's webhook could reach any path on that private origin. Non-admin webhooks now validate and connect with an empty allowlist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(saves): bound total decompressed size when hashing zip archives Zip content hashing capped each entry but not the archive, so many entries each under the cap could still decompress and hash far more than any real save or memory card holds. Budget the decompressed bytes across the whole archive and cap the entry count; callers keep treating an over-budget archive as an unknown hash. The chunked, budgeted entry reader is shared with the memory card archive check, and the RetroArch store path now hashes off the event loop like its siblings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(psp): clamp LZ4 literal and match copies to the ZISO block size The ZISO block decoder appended literals and copied matches for their full encoded length before checking the output size, and an LZ4 length can be extended without bound by 0xFF bytes. A small crafted block could therefore expand far past the block size before being truncated. Clamp each copy to the room left in the block, stop once it is full, end the block on a truncated match offset, and copy matches with slices instead of a per-byte loop (overlapping matches repeat their pattern). Output for valid blocks is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(auth): revoke OAuth tokens when a user's credentials change A password change, admin reset, reset-link reset or rename cleared the account's web sessions, but its OAuth access tokens kept working until they expired and its refresh tokens could still be exchanged at /api/token. Revoking a user's credentials now also records a per-username revocation time in Redis, kept for the longest token lifetime. Bearer validation and refresh consumption reject any token whose iat is at or before it. OAuth tokens now carry a sub-second iat, so a login right after the change still works; a token without iat counts as older than any revocation. The revocation is keyed by the token's sub, the same username sessions are keyed by, so a rename revokes tokens issued under the old name even if another account later takes it. Client (API) tokens are left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(api): reject local file URLs for user-supplied covers and manuals file:// and launchbox-file:// URLs are meant for covers and manuals that a scan records from gamelist.xml or LaunchBox metadata. The collection create/update endpoints and the ROM update endpoint passed a user-supplied url_cover (and url_manual) straight to the resource handler, which copied whatever library file it named into the entity's resources. That let any user with collections.write or roms.write pull files they cannot otherwise read, including those of hidden platforms and ROMs. These endpoints now answer 400 for a local file URL, unless it is the value already stored, which the edit forms echo back on every save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(resources): bound cover downloads and decodes Remote covers, screenshots, manuals, badges and media files were streamed to disk with no size limit, and a gzip-encoded body was read whole and inflated in memory. Downloads now go through one helper that counts bytes against MAX_ASSET_UPLOAD_SIZE_BYTES, inflates gzip incrementally under the same cap, and aborts past it, so the partial file is removed and any earlier copy kept. Covers are also bounded once on disk: a still image whose header declares more than MAX_COVER_PIXELS is discarded before it is decoded (and an uploaded one is refused with a 400), and a DecompressionBombError while deriving the small cover now discards the download instead of failing the request and leaving the file behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: fix mypy errors in the new tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: address Greptile review on permission and input hardening - Date OAuth tokens to before the credential check, so a password change that lands during the check revokes the tokens it issues. - Apply ROM visibility to play sessions in SQL, before the page slice. - Reject truncated gzip bodies and inflate every gzip member. - Shorten the zip budget comment; stream real httpx2 responses in tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: apply code-review findings on permission hardening Revoke OAuth tokens and sessions on user deletion, apply ROM visibility to GET /states/{id}, validate update_collection rom_ids, run get_rom_filters off the event loop, and reuse the shared httpx client factory for webhooks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: apply simplify pass on permission hardening Read the OAuth revocation stamp through the async cache, share the play-session batch-size check, raise a plain OSError for oversized downloads, and drop a dead slice in the LZ4 decoder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: apply review-polish pass on permission hardening Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: state that ROM visibility is enforced as access control Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(assets): hide saves, states, screenshots and memory cards on hidden ROMs Visibility is access control, so per-id save/state/screenshot routes now 404 when the save's ROM is hidden from the caller (hidden ROM, hidden platform or age limit), and the save/state lists and identifier lists leave those rows out in SQL. GET /api/saves/summary 404s on a hidden ROM. Memory cards on a hidden platform 404 on every per-id route, drop out of both lists, and can't be created against a hidden platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(saves): answer a hidden ROM's save summary like a missing one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(permissions): enforce ROM visibility in sync, installs and feeds Hidden ROMs/platforms and age-limited ROMs are access control, so the paths that skipped the caller's visibility now apply it: - sync negotiate: saves on hidden ROMs are neither offered, paired nor reported as conflicts; a client save on one negotiates like an unknown ROM - push-pull SSH sync: resolves the device owner's visibility and skips saves on hidden ROMs in both directions - device installs: list and claim leave out requests whose ROM became hidden (they stay pending), and outcome notifications don't name it - recommendations: a hidden seed ROM is no longer named - music playlists: track_count counts only tracks on visible ROMs - audit events: firmware targets on hidden platforms are filtered - setup library: supported platforms honour the caller's visibility - feeds: a hidden platform found by slug reads as missing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(visibility): hide ROMs from virtual collections, stats and scan events Virtual collections apply the caller's visibility in SQL: a collection with no visible member is left out (404 by id), member ids and covers skip hidden ROMs, and the limit counts only visible collections. Stats save, state and screenshot totals skip assets of hidden ROMs. Scan events no longer broadcast to every socket. Progress and end events go to a scan room that sockets of users holding platforms.write or tasks.run join on connect. scanning_rom and scanning_platform go to the user rooms of those followers who can see that ROM or platform, resolved once per scan and grouped by visibility. get_rom_audience now builds on a shared get_user_visibilities. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: apply code-review findings on ROM visibility enforcement Match virtual collection members by ROM id, build the cover visibility clauses once, filter feed platforms by visibility in SQL, resolve every id before a batch save or state delete, filter push-pull saves in the query, and narrow the hides query to the requested users. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: apply simplify pass on ROM visibility enforcement Require an explicit visibility filter on the saves, states and memory card queries, share one roms_facets visibility join and one owned-asset helper, filter virtual collection members by hidden ids, batch the scan audience's scope lookup, and move the empty-room emit guard into socket_handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: start the scan audience before emitting from scan_rom Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: apply humanizer pass on the visibility rule Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(streaming): don't mount a memory card on a hidden platform Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: address Greptile review on ROM visibility enforcement Refresh a running scan's audience after a permission change, fix the precedence of the scan-room join assertion, and narrow mock await_args before reading them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * revert: drop per-visibility scan event audience Scan events go back to every socket. Removes handler/scan/audience.py, the scan room join on connect, the permissions generation bump and the batched OAuth scope resolution that only the audience used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
37e4ca304d |
fix: permission, validation and resource-limit hardening (#5496)
* fix(sync): cap play sessions on sync completion and require roms.user.write The completion endpoint fed an unbounded play_sessions list to the same ingest as POST /api/play-sessions, which allows 100 per batch and requires roms.user.write. Apply both rules before the session is completed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(config): reject empty platform binding and version values config.yml exits on load when a platforms or versions value is empty, so the API must not write one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(collections): require smart collection criteria to be a JSON object Any other JSON value was stored, then failed the response schema and broke the smart collection list for every user who could see the collection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(stats): require roms.read on /api/stats Anonymous callers were served counts over the whole library, including platforms and ROMs hidden from users. The UI only calls it after login. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(permissions): apply ROM visibility to filters, saves, play sessions and collection removal /api/roms/filters aggregated facet values over the whole library, GET /api/saves/{id} and GET /api/play-sessions returned the caller's own rows on hidden ROMs, and removing ROMs from a collection could drop members hidden from its owner. The facet visibility clauses move onto RomVisibilityFilter so stats and filters share them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(webhooks): keep non-admin webhooks off the admin's internal metadata origins The SSRF exception for a self-hosted Playmatch or Hasheous applied to every request, so a user's webhook could reach any path on that private origin. Non-admin webhooks now validate and connect with an empty allowlist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(saves): bound total decompressed size when hashing zip archives Zip content hashing capped each entry but not the archive, so many entries each under the cap could still decompress and hash far more than any real save or memory card holds. Budget the decompressed bytes across the whole archive and cap the entry count; callers keep treating an over-budget archive as an unknown hash. The chunked, budgeted entry reader is shared with the memory card archive check, and the RetroArch store path now hashes off the event loop like its siblings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(psp): clamp LZ4 literal and match copies to the ZISO block size The ZISO block decoder appended literals and copied matches for their full encoded length before checking the output size, and an LZ4 length can be extended without bound by 0xFF bytes. A small crafted block could therefore expand far past the block size before being truncated. Clamp each copy to the room left in the block, stop once it is full, end the block on a truncated match offset, and copy matches with slices instead of a per-byte loop (overlapping matches repeat their pattern). Output for valid blocks is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(auth): revoke OAuth tokens when a user's credentials change A password change, admin reset, reset-link reset or rename cleared the account's web sessions, but its OAuth access tokens kept working until they expired and its refresh tokens could still be exchanged at /api/token. Revoking a user's credentials now also records a per-username revocation time in Redis, kept for the longest token lifetime. Bearer validation and refresh consumption reject any token whose iat is at or before it. OAuth tokens now carry a sub-second iat, so a login right after the change still works; a token without iat counts as older than any revocation. The revocation is keyed by the token's sub, the same username sessions are keyed by, so a rename revokes tokens issued under the old name even if another account later takes it. Client (API) tokens are left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(api): reject local file URLs for user-supplied covers and manuals file:// and launchbox-file:// URLs are meant for covers and manuals that a scan records from gamelist.xml or LaunchBox metadata. The collection create/update endpoints and the ROM update endpoint passed a user-supplied url_cover (and url_manual) straight to the resource handler, which copied whatever library file it named into the entity's resources. That let any user with collections.write or roms.write pull files they cannot otherwise read, including those of hidden platforms and ROMs. These endpoints now answer 400 for a local file URL, unless it is the value already stored, which the edit forms echo back on every save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(resources): bound cover downloads and decodes Remote covers, screenshots, manuals, badges and media files were streamed to disk with no size limit, and a gzip-encoded body was read whole and inflated in memory. Downloads now go through one helper that counts bytes against MAX_ASSET_UPLOAD_SIZE_BYTES, inflates gzip incrementally under the same cap, and aborts past it, so the partial file is removed and any earlier copy kept. Covers are also bounded once on disk: a still image whose header declares more than MAX_COVER_PIXELS is discarded before it is decoded (and an uploaded one is refused with a 400), and a DecompressionBombError while deriving the small cover now discards the download instead of failing the request and leaving the file behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: fix mypy errors in the new tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: address Greptile review on permission and input hardening - Date OAuth tokens to before the credential check, so a password change that lands during the check revokes the tokens it issues. - Apply ROM visibility to play sessions in SQL, before the page slice. - Reject truncated gzip bodies and inflate every gzip member. - Shorten the zip budget comment; stream real httpx2 responses in tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: apply code-review findings on permission hardening Revoke OAuth tokens and sessions on user deletion, apply ROM visibility to GET /states/{id}, validate update_collection rom_ids, run get_rom_filters off the event loop, and reuse the shared httpx client factory for webhooks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: apply simplify pass on permission hardening Read the OAuth revocation stamp through the async cache, share the play-session batch-size check, raise a plain OSError for oversized downloads, and drop a dead slice in the LZ4 decoder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: apply review-polish pass on permission hardening Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(play-sessions): filter rom_id and device_id on PlaySession after the visibility join Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
900fe515ea |
fix(sync): match RetroArch saves named after a ROM's files (#5445)
* fix(sync): match RetroArch saves named after a ROM's files RetroArch names a save after the file it launched, so a disc or a translation inside a multi-file game folder uploaded a save that matched no ROM. When no ROM carries the name, saves now resolve to the ROM owning a file with that stem. Those saves stay unslotted under their own name, since a ROM's autosave lineage holds one save per core and the discs would overwrite each other. States keep matching on the ROM name only, because their slots are advertised under it. Fixes #5364 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sync): write a case-variant reupload to the stored save's own file Addresses Greptile review on #5445. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sync): match a stored save's name in any case on PostgreSQL The RetroArch save lookup relied on MariaDB's case-insensitive collation, so on PostgreSQL a reupload in another case created a second save instead of replacing the stored one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5270c5d31e |
fix(sync): file a screenshot sent ahead of its state past a stream capture (#5208)
* fix(sync): file a screenshot sent ahead of its state past a stream capture A Cloud Sync client sends a slot's screenshot before the state it belongs to. With a stream capture serving the slot, the screenshot was filed under the capture's name and wrote over the capture's own thumbnail. The screenshot now goes to the state the slot's next upload writes to: the slot's newest non-capture state, or the canonical name when the upload will create one. A copy of the capture's own screenshot sent back is left alone. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * refactor(sync): address Greptile review on the stream capture checks Move the capture copy checks for a state and a screenshot upload out of the endpoint into the sync handler, and fold the core_library_name, prune_state_history and Stream.vue comments to two lines. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Zach Clendenen <zclendenen@yahoo.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
261178cb25 |
fix(streaming): share RetroArch stream saves and states with Cloud Sync (#5197)
A streamed RetroArch exit's save landed in "No slot", and the stream's states were filed under a different emulator than the one Cloud Sync and the other RetroArch clients use, so neither side could see the other's. A streamed exit's save is now stored as an `autosave` version, like the other clients' autosaves. Stream saves and states are filed under the core's RetroArch folder, which the broker reports as `library_name`; a broker that doesn't is filed under the core id. A stream resumes from any state in the booted core's folder, including other clients' states and ones filed under an alias of the folder, and the picker's core rule gains the folder's names so it offers them too. Cloud Sync shares the slot with stream captures but never writes over or deletes one: an upload goes to the slot's newest non-capture state or creates one, sending a capture's own bytes back is a no-op, and a delete removes the slot's other states and leaves captures in place. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
be6ad905b1 |
fix(sync): serve the newest on-disk RetroArch state in a slot (#5193)
* fix(sync): resolve RetroArch paths across emulators sharing a core folder Several RomM emulator ids map to one RetroArch folder (mednafen_psx_hw, beetle_psx_hw and the raw "Beetle PSX HW" all sync through saves/Beetle PSX HW/). The manifest built paths from whichever id an asset carried, but GET parsed the folder back to the canonical id and matched it exactly, so an asset filed under another alias was advertised and then 404'd. Uploads also started a second autosave history beside the alias's. The manifest now lists the newest asset per folder, and GET, PUT and DELETE resolve a path across every alias. Rewrites of an existing unslotted save or state stay under that row's own emulator. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): prefer on-disk alias saves and share newest-per-key grouping pr-ready step 2 (code-review --fix). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(sync): one alias helper and a lineage computed once pr-ready step 3 (simplify). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): type the alias fixture's asset kind pr-ready step 4 (review-polish). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): isolate the asset dir per RetroArch sync test The alias tests write different bytes to the same asset paths, and user and ROM ids repeat across xdist worker databases, so parallel runs raced on those files. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): serve the newest on-disk RetroArch state in a slot Missing states are dropped before slot grouping for the manifest and reads, so a newer missing state (or alias) no longer hides an older one still on disk. A PUT still matches the missing row and revives it in place. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): fall back past a RetroArch file that vanished unflagged Addresses Greptile's review on #5193: a state whose file was deleted before `missing_from_fs` was set still won its slot. The manifest now rebuilds when hashing flags an asset, and GET flags a missing file and resolves again, so an older asset at the path is listed and served. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
57ebac8efe |
perf(sync): resolve RetroArch core aliases in one query (#5192)
* fix(sync): resolve RetroArch paths across emulators sharing a core folder Several RomM emulator ids map to one RetroArch folder (mednafen_psx_hw, beetle_psx_hw and the raw "Beetle PSX HW" all sync through saves/Beetle PSX HW/). The manifest built paths from whichever id an asset carried, but GET parsed the folder back to the canonical id and matched it exactly, so an asset filed under another alias was advertised and then 404'd. Uploads also started a second autosave history beside the alias's. The manifest now lists the newest asset per folder, and GET, PUT and DELETE resolve a path across every alias. Rewrites of an existing unslotted save or state stay under that row's own emulator. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): prefer on-disk alias saves and share newest-per-key grouping pr-ready step 2 (code-review --fix). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(sync): one alias helper and a lineage computed once pr-ready step 3 (simplify). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): type the alias fixture's asset kind pr-ready step 4 (review-polish). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): isolate the asset dir per RetroArch sync test The alias tests write different bytes to the same asset paths, and user and ROM ids repeat across xdist worker databases, so parallel runs raced on those files. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * perf(sync): resolve RetroArch core aliases in one query The saves handler now filters on a collection of lineages and looks up a file name across several folders, so the RetroArch alias resolvers issue one query each instead of one per alias. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * perf(sync): filter a RetroArch delete to autosave and unslotted saves in SQL Addresses Greptile's review on #5192: saves_at_path loaded every slot of the matching lineages and dropped the named slots in Python. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
79d1feba6c |
fix(sync): resolve RetroArch paths across emulators sharing a core folder (#5191)
* fix(sync): resolve RetroArch paths across emulators sharing a core folder Several RomM emulator ids map to one RetroArch folder (mednafen_psx_hw, beetle_psx_hw and the raw "Beetle PSX HW" all sync through saves/Beetle PSX HW/). The manifest built paths from whichever id an asset carried, but GET parsed the folder back to the canonical id and matched it exactly, so an asset filed under another alias was advertised and then 404'd. Uploads also started a second autosave history beside the alias's. The manifest now lists the newest asset per folder, and GET, PUT and DELETE resolve a path across every alias. Rewrites of an existing unslotted save or state stay under that row's own emulator. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): prefer on-disk alias saves and share newest-per-key grouping pr-ready step 2 (code-review --fix). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(sync): one alias helper and a lineage computed once pr-ready step 3 (simplify). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): type the alias fixture's asset kind pr-ready step 4 (review-polish). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): isolate the asset dir per RetroArch sync test The alias tests write different bytes to the same asset paths, and user and ROM ids repeat across xdist worker databases, so parallel runs raced on those files. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): delete every aliased state in a slot and prefer one on disk Addresses Greptile review on #5191: a slot's state is picked live-first across aliases, so a newer missing alias no longer hides an older one on disk, and DELETE removes every state in the slot so an older alias can't resurface at the same path. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
38dfb208f0 |
fix(streaming): file RetroArch streaming exits as raw saves (#5174)
* fix(streaming): keep foreign saves offered when the import-spec check fails A broker that misses the 5 s import-spec deadline used to read as "imports nothing": the Saves tab vanished and foreign picks were refused with "Save is not a restorable archive". Keep the last good answer in Redis so every worker can fall back on it, cache 404s for five minutes instead of forever, answer a pick that can't be checked with a retryable 503, and refetch the streaming config whenever the Stream page mounts. * fix(streaming): code-review fixes for the import-spec fallback Hold a fallback answer for 10 s so one claim's checks don't each wait out the broker timeout, read the stored answer back through the broker response parser, and warn about a pre-import broker once per worker instead of at every cache expiry. * refactor(streaming): simplify pass on the import-spec fallback Make ImportSpecUnavailable the 503 itself so the save and state pickers no longer convert it by hand, and store the broker's own response body as the last answer instead of rebuilding its shape. * chore(streaming): review-polish on the import-spec fallback Trim the cache comments and the exception docstring, fit the 503 detail within the line limit, and annotate the fresh-worker test dict for mypy. * docs(streaming): humanizer pass on import-spec comments and test docstrings * fix(streaming): tell lasting import-spec failures from passing ones Only timeouts, connection errors, 5xx and 429 fall back to the broker's last answer. A refused request (401, other 4xx) or a reply RomM can't read caches no imports for 30 s and logs an error, so a pick gets a refusal instead of an endless retry. A 404 from a broker that answered before uses that answer, since it is likelier a restart behind a proxy than a downgrade. * fix(streaming): ask for a retry when a picked state can't be checked An older save with the newest state resumes the pick only through an import, so an unanswered import-spec check now returns the 503 instead of launching from the older archive's own state. * fix(streaming): share an in-flight config request App load and the Stream page both fetch the config; two requests could land out of order and leave the older answer in place. (Stability item 5.) * fix(streaming): hold the resume picker until the fresh config lands What the broker imports decides which saves and states are on offer, and the app-load config can predate its answer. The panel shows a spinner until the Stream page's own refetch settles, so a pick can't vanish under the player. (Stability item 4.) * fix(streaming): ask every platform's broker at once on /config The checks ran on the default thread pool (cpu+4 threads), so a broker serving more platforms than that cost one timeout per wave: 10.7 s for 14 platforms on a 6-CPU dev box with a silent broker. The Stream page's picker now waits on /config, so the checks get a pool of their own. * fix(streaming): address Greptile review on the import-spec fallback - Play waits on the fresh config with the resume picker, so it can't send a preselected state the player can't see yet. - The streaming store gets a reset() for logout, and a config reply asked for as the previous account is dropped instead of landing in the next one. - The configFresh write after the refetch checks useIsAlive(). - Trimmed the require_import_spec docstring, the configFresh comment and the /config pool comment to the house length. - Declined: a worker-wide pool for the /config checks. Each request's threads end within the broker timeout, and a shared bounded pool would bring back timeout waves under concurrent loads. * fix(streaming): share /config broker checks across requests Addresses Greptile's re-raised finding on #5174 that each /config request opened its own pool of up to 64 threads, so overlapping page loads during a silent broker multiplied the worker's threads. - The checks run in one worker-wide pool, and a check already in flight for the same container and platform is joined rather than asked again, so concurrent page loads hold no more threads than one does, with no queued-timeout waves. - Callers await the shared run through asyncio.shield, so a request that disconnects doesn't cancel the check others are waiting on. * fix(streaming): file a RetroArch exit's save raw and boot the newest save A RetroArch exit holding one .srm and its states is no longer stored as a .saves.zip: the .srm is filed bare under the core's emulator name with a timestamped name, and each state goes through the state store. Exits with more than one save, a memory card, or unlabelled members still keep the zip. A launch with no pick now boots the newest save, raw or zip. A newer bare .srm goes through the broker's save import when the broker accepts one, and the launch screen defaults to the same save. * fix(streaming): keep the exit zip when a raw save can't be filed safely pr-ready step 2 (code review). - Keep the zip for a core that isn't one plain folder name, a malformed manifest kind, a member that fails to unpack, or a broker that doesn't import saves. - Fall back to the newest archive when the default raw save fails to import. - File exit states oldest first; one unreadable stored state no longer drops the rest. - Rename locals that shadowed the archive module; fix a test return type and a stale comment. * refactor(streaming): simplify the default save comparison pr-ready step 3 (simplify): default_save reuses _newest's ordering, and newestSave takes the first match in the newest-first list. * docs(streaming): trim the raw-save docstrings pr-ready step 4 (review-polish). * fix(streaming): rank saves by their last write and read .ZIP as an archive The web player writes into its existing save row, which only moves updated_at, so ranking by created_at let a stream with no pick boot an older streaming zip over newer web-player progress. The backend default and the launch screen now rank by updated_at, and the picker dates rows by it. Upper-case .ZIP saves are now read as archives on both sides, to match the web player's case-insensitive guard. * feat(states): hash states so duplicate checks skip reading files Adds states.content_hash (migration 0149), filled on every state write: streaming capture, the states upload and update endpoints, the scan and the RetroArch sync push. The streaming duplicate check compares hashes and falls back to reading the file for rows stored before this, which are not backfilled. * fix(streaming): leave an untouched default off the claim and skip missing saves Review items 1 and 2: a default sent as a pick bypassed the zip fallback, and a save marked missing could become the newest. * fix(streaming): code-review fixes for raw exit filing and state hashing pr-ready step 2: keep the zip when a state can't be filed, don't treat a missing state file as a duplicate, fall back to the native archive when a defaulted save fails, hash off the event loop, count filed states as new. * docs(streaming): review-polish, trim the newest-save comment * fix(streaming): bind the background exit pull's states to the swapped disc Decision 1: the exit save job filed states without the session's disc id, so on a multi-disc game its copy could lose the disc binding. The second copy is still dropped by the hash dedupe. * fix(streaming): keep the exit zip when one of its states fails to store Decision 2: a state that threw on store was logged and lost, since the zip holding it was dropped. The zip holds the same .srm, so booting it as the default loses nothing. * fix(sync): keep updated_at when RetroArch sync flags a vanished save or state * fix(streaming): record a legacy state's hash when dedupe reads its bytes * fix(streaming): file a RetroArch exit's auto state raw instead of keeping the zip The auto state now goes into the state history under its own capture stamp, so an exit carrying one files its .srm raw like any other. It is never hydrated, and a resume pick of it is refused, since the broker would file it into its numbered working slot. * fix(streaming): hydrate the newest state still on disk A newer row sync flagged as gone from disk made hydrate push nothing. It now skips such rows the way the save picks already do. * docs(streaming): note the auto-state refusal in resolve_resume_state * fix(streaming): resume a RetroArch auto state like any other state The broker files any pushed state into its working slot, so .state.auto reads as slot 0 like a bare .state. Hydrate and the resume pick now push it instead of skipping or refusing it. * fix(streaming): address Greptile review on raw RetroArch exits - A default .srm the broker refuses at activate now boots the newest native archive instead of failing the launch. Only a default save that rode the import alone falls back; a hand pick still fails. - Exit states the history hasn't seen are filed just under the next state it already holds, so an older slot no longer heads the history over the exit capture teardown filed first. - A raw exit save is skipped only when it matches the newest usable save, so returning to an older save records the play, and a match on a row whose file is gone no longer deletes the new copy. - Stream.test.ts clicks the rendered play button instead of casting the view model to call onPlay. - Trim the raw-exit docstrings to one sentence. * fix(streaming): reserve a free version name for a raw RetroArch exit save Addresses Greptile: the exit's .srm took a second-resolution tag without checking whether another save held that name, so it could overwrite one. Also compares updated_at naively in the mark-missing test, which failed on PostgreSQL's UTC-aware column. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(streaming): file each RetroArch exit state on the disc it was saved on Addresses Greptile: every state in the exit archive took the session's final disc, so a hotkey slot saved before a swap resumed on the wrong one. The session now keeps each swap with its time, and a session that ran more than one disc files each state by its archive timestamp. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
3b8eabdb77 |
feat(sync): sync RetroArch Cloud Sync saves through save slots (#5170)
* feat(sync): sync RetroArch Cloud Sync saves through save slots RetroArch saves were unslotted and overwritten in place, so they never reached the slot-based sync the native clients use, and a bad upload replaced the only copy. A save path now serves the newest slotted version for its ROM, core and extension, from any slot, under RetroArch's own file name. An upload adds a version to that slot (or autosave), skips unchanged bytes, and prunes to MAX_SAVES_PER_SLOT. A delete removes every save the path covers, so none resurfaces on the next sync. Unslotted saves keep serving until the first slotted upload; PSP bundles and states are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): lock RetroArch save uploads and prune per core and extension Addresses Greptile's review on #5170: - Move the RetroArch save upload into sync_handler.store_save_version, leaving the endpoint to validate and map the result to a status. - Hold a Redis lock per (user, rom, core, extension) across the lookup, write, scan and row update, so concurrent same-second uploads never file two rows over one tagged file. A lock timeout answers 503. - Prune only the uploaded path's core and extension in the slot, so another core's or a .rtc's current save is never dropped. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): pr-ready code-review fixes for RetroArch save slots - Scope an extensionless prune to dotless file names, since every name ends in an empty extension. - Treat only NULL slots as unslotted in the manifest, matching the query it replaced and the PSP bundle lookup. - Share one helper for the slot versions a RetroArch path covers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(sync): pr-ready simplify pass for RetroArch save slots - Scope a slot prune by save ids, so the versions a RetroArch path covers are decided once in Python instead of again in SQL. - One newest-per-key helper for states and save versions, and resolve_save_by_slot reuses it. - A canonical_save_file_name helper next to the state one. - The upload builds its tagged name once, checks its length in the handler, and finds a same-second version in the list it already loaded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(sync): pr-ready review-polish pass Drop a comment the canonical_save_file_name helper now says. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): map RetroArch saves onto autosave lineages with unique version names - Only RetroArch's .srm goes through slots, as the autosave versions of its ROM and core. Companion files such as .rtc stay single unslotted saves, so a slot never offers a clock file as the save. - RetroArch reads, writes and deletes in autosave only, leaving named slots alone. - Every slot prune, web uploads included, is scoped to the uploaded save's lineage (emulator and extension), so one core's uploads never drop another's only save. - The manifest lists the newest version under the client's spelling of the game when it still names the ROM. - reserve_version_name moves a taken tag on a second and claims it in Redis, so same-second, concurrent or repeated-hour uploads from either endpoint never share a file. The RetroArch lock and its 503 go. - The manifest reads only the newest version per lineage, through one window query. - An upload is hashed before it is written, so an unchanged re-send writes nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): seed the client-spelled save instead of uploading it Uploading TEST_ROM.srm only resolves to the test_rom ROM under MariaDB's case-insensitive collation, so the test 409'd on PostgreSQL. Seeding the version directly still checks that the manifest keeps the client's spelling of the game. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): resolve RetroArch saves to ROMs case-insensitively on PostgreSQL Cloud Sync matches a save's game name to a ROM's fs_name_no_ext. MariaDB's collation ignores case, but PostgreSQL compared exactly, so TEST_ROM.srm never reached the test_rom ROM. PostgreSQL now compares lowercased names, served by a new expression index (0150), and the endpoint test uploads the differently-cased name again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): address Greptile review on RetroArch save slots - add_save derives the prune lineage from the tagged name it stores, so a dotted upload such as game.rev.srm is counted against its own versions. - Deleting a RetroArch .srm path also removes unslotted saves in that lineage spelled in another case, which the manifest hid behind the autosave head and PostgreSQL's exact match left behind. - reserve_version_name looks up existing versions off the event loop. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
75e8a9efae |
fix(sync): keep RetroArch Cloud Sync from stalling the event loop (#5171)
* fix(sync): keep RetroArch Cloud Sync from stalling the event loop Basic auth ran its bcrypt check (~250ms) on the event loop for every WebDAV request, and the manifest ran its queries there too, so parallel RetroArch requests queued behind each other. Both now run in a thread. Cloud Sync resolves every save and state to a ROM by fs_name_no_ext, which no index led with; 0149 adds one so unmatched uploads fail fast. The upload dialog now offers a core for saves as well as states, so a manually uploaded save lands in the core folder RetroArch reads, and its slot hint says only unslotted saves reach RetroArch. Refs #5158 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(sync): cover manifest queries running off the event loop Addresses Greptile review on #5171: trim the 0149 migration docstring to its summary, annotate the new MockConnection constructor, and add regression tests that build_manifest and list_manifest_paths query from a worker thread. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(auth): mark Basic-auth users active off the event loop pr-ready step 2 (code-review): run the user lookup, password check and set_last_active in one worker-thread hop, and test that SaveDataTab offers save cores and forwards the picked core on upload. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(v2): build SaveDataTab test saves and states from shared fixtures pr-ready step 3 (simplify): replace the hand-cast UserSaveSchema and UserStateSchema stubs with saveFixture/stateFixture plus toUserSave/toUserState. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(sync): drop restating index comment and type the test spy pr-ready step 4 (review-polish): remove the comment that only restated idx_roms_fs_name_no_ext, and type the manifest test's get_saves spy so mypy passes across the backend. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(auth): check the password grant's credentials off the event loop The OAuth password grant ran bcrypt (~250ms) on the event loop, stalling every other request the worker was serving. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(sync): run RetroArch WebDAV database work off the event loop GET, PUT, DELETE and PROPFIND resolved ROMs, looked up and wrote save, state and screenshot rows, and listed whole platforms synchronously inside async handlers; the PSP bundle helpers did the same. Each now runs that work in a worker thread. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(saves): keep another core's same-named save on upload A slot-less upload matched an existing save by file name alone, so uploading game.srm for a second core rewrote the first core's row to the new folder and deleted its file. The lookup now only matches a save made with the requested core. Clients that send no core still match any, so device conflict detection is unchanged, preferring a save filed under no core. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(v2): file a save picked with a core out of the slots RetroArch Cloud Sync only lists unslotted saves, so picking a core in the upload dialog moves an untouched slot from autosave to "No slot", and clearing the core moves it back. A slot the user picked is kept. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * revert(i18n): restore the original upload slot hint Picking a core now files a save out of the slots, so the hint no longer needs to explain RetroArch Cloud Sync. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
3f13d1e752 |
fix(sync): store RetroArch Cloud Sync blobs under the assets volume (#5155)
The config/, thumbnails/ and system/ blobs lived at /romm/retroarch_sync, which no documented mount covers, so they sat in the image's anonymous /romm volume and were lost on `compose down`/`up`, `-V`, or a docker rm/run upgrade. RetroArch can then treat the missing files as deleted on the server and drop its local copies. They now live at assets/users/<user>/retroarch/<category>/, beside the user's saves and states. The old path never shipped in a release, so no data migration is needed. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
c4f4d22687 | chore(mypy): require coded ignores and flag stale ones, type protected_route (#4794) | ||
|
|
2c71226887 | ci: run mypy in its own workflow instead of through Trunk (#4724) | ||
|
|
bb9aa28ea6 |
chore(sync): review-polish pass on the RetroArch manifest perf work
Rename cached_md5s to cached_hashes, since it also caches PSP member hash maps, and keep its docstring to one line. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
0c7633f4bb |
refactor(sync): apply simplify pass to the RetroArch manifest perf work
- Key PSP member hashes on the bundle's content hash, computed once in a thread, cached via the shared batch helper, and guarded only on write - Build only the requested tree for a PROPFIND listing - Walk blobs with iter_files, share the bundle limit check and reader - Drop the derivable ManifestAsset.parent_path and the closure factories Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
94335b941c |
perf(sync): batch RetroArch manifest hashing and list PROPFIND paths unhashed
- Read every asset and blob hash from one MGET, compute misses with bounded concurrency and write them back in one pipeline. - Split the manifest into a path builder and a hashing layer; PROPFIND of saves/ and states/ now lists paths without hashing assets, walking blobs or inflating PSP bundles (member names come from the zip central directory). - Walk blob directories once off the event loop with os.scandir, reusing each entry's size and mtime for the hash cache key. - Build PSP bundles off the event loop and prime the member-hash cache on write so the next manifest skips inflating them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
603e3b0c93 |
fix(sync): keep state screenshots separate per core
RetroArch names a slot's state the same under every core, and its screenshot was filed per ROM, so two cores' `<rom>.state.png` shared one file and one row. File them under a per-core screenshots folder, upsert by path, and only match a state to a screenshot in its own core's folder or the ROM-level one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
7e7e5a671d |
refactor(sync): apply simplify pass
- Enforce the upload size cap on streamed bytes in the middleware, so chunked uploads to every guarded route are bounded, not just RetroArch - Flag vanished assets missing_from_fs from the manifest instead of re-hashing them every sync - Batch state screenshot lookups, filter PSP bundles in SQL, hash files in one thread hop, and read only the requested PSP bundle members - Reuse remove_screenshot and content_hash_of_bytes, merge the save and state PUT branches, drop dead checks and trim docstrings and tests Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
918afcf1df |
fix(sync): apply code-review xhigh findings
- Stream RetroArch PUT bodies with a byte cap, so a chunked upload can't bypass the Content-Length check and exhaust memory - Map shared core folders back to the mednafen_* ids the web player uses - Enforce PSP bundle limits on write, return 409 for invalid bundles, and never delete an unreadable bundle when removing one member - Challenge the kiosk guest so RetroArch sends credentials - Move a slot-matched state's row with its bytes, scan saves under the name actually written - Reject NUL path segments and core folder names over the emulator column length - Cache PSP bundle member hashes in the manifest Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
49e8d380e9 |
refactor(sync): rename the RetroArch blob handler to retroarch_sync
FSRetroArchSyncBlobHandler becomes FSRetroArchSyncHandler, and SYNC_RETROARCH_BLOB_BASE_PATH becomes SYNC_RETROARCH_BASE_PATH, stored under /romm/retroarch_sync. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
7c7f27d701 |
refactor(sync): mount RetroArch Cloud Sync under /api/sync/retroarch
The manifest protocol is RetroArch's own, so name it after RetroArch rather than its WebDAV transport, and group it with the existing sync code: endpoints/sync/ becomes a package with the RetroArch router as a subroute, and the handlers move under handler/sync/retroarch/. Settings move into the SYNC config section as SYNC_RETROARCH_*. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |