States have no `slot` column (unlike saves), so a state created through
RomM's own web player -- named with a display label and timestamp, not a
RetroArch slot number -- was surfaced in the cloud-sync manifest under its
raw file name. Verified live: RetroArch's Load State menu only ever offers
numbered slots 0-999, so a synced file named otherwise downloads
successfully but is never reachable from that menu.
Mirrors the reasoning already used for the retroarch-webdav-romm shim
project's manifest builder: states are grouped by (rom, emulator, slot
suffix) via the file name's trailing .state/.state<N>/.state.auto pattern,
and the newest state in each bucket -- regardless of whether it came from
RetroArch itself or the web player -- is advertised under the canonical
name RetroArch's own upload for that slot would carry. GET/DELETE resolve
that canonical name back to the same bucket via resolve_state_by_slot, so
serving and deleting agree with what the manifest advertised even when the
underlying row's real file name differs.
RetroArch's cloud-sync core-name segment uses its own directory casing
(e.g. "Snes9x"), while RomM's emulator field convention is the lowercase
libretro core id (e.g. "snes9x") -- the same convention its own web player
matches saves against exactly. Storing the raw RetroArch casing made a
synced save invisible in RomM's web player, and could hand RetroArch back
a folder name its local install never uses.
Adds a small translation table (ported from the community
romm-retroarch-sync project) plus a safe universal normalization for the
write direction. Cores outside the table round-trip unchanged rather than
guessing at an unverified casing.
RetroArch's Cloud Sync also offers a config/, thumbnails/, and system/
category alongside saves/states, none of which belong to a ROM. The
previous behavior rejected them with 409 so RetroArch would keep retrying
locally instead of losing data. This stores them as plain per-user files
under CLOUD_SYNC_BLOB_BASE_PATH (FSCloudSyncBlobHandler) instead, namespaced
by user so two RetroArch installs syncing to the same RomM instance under
different accounts don't clobber each other's files, and includes them in
the manifest alongside saves/states.
RetroArch's cloud-sync driver diffs a JSON manifest of {path, hash} entries
and then GETs/PUTs/DELETEs individual files, so it needs only a narrow slice
of WebDAV and never issues PROPFIND. Expose that slice at /api/cloud-sync so
save files and states sync straight into RomM's existing asset storage.
Assets are matched to a ROM by file name, and the optional core folder maps to
the emulator field that already namespaces asset storage. The router gates
itself rather than using @protected_route, so it can answer a 401 challenge
instead of a 403, and error responses carry no body because RetroArch's client
mishandles large ones.
Closes#2313
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>