* 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>
* fix(docker): boot when the container runs as a non-default UID
Unraid runs the container as 99:100, which can't write to the image's
/romm (owned by 1000, mode 755), only to the mounted subfolders. The
PSP pending dir at /romm/cache/retroarch_sync was created at import
time, so every gunicorn worker failed to boot.
- Buffer pending PSP save files under the user's assets folder
(assets/users/<user>/retroarch/psp_pending/), beside the other
RetroArch Cloud Sync files and outside the client-reachable blob
categories.
- Move the zip and rom-converto download caches to /tmp/romm/cache,
and point nginx's internal /cache/ alias there.
- Put gunicorn's control socket in /tmp/gunicorn instead of
$HOME/.gunicorn, since HOME is / for that UID.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(docker): honor ROMM_TMP_PATH for caches, explain an unwritable sync folder
- The download caches live under $ROMM_TMP_PATH/cache when it's set,
so installs with a small Docker disk (Unraid's docker.img) can point
them at a share. The entrypoint exports the same path for nginx's
/cache/ alias.
- With ENABLE_SYNC_FOLDER_WATCHER on and /romm/sync not writable, /init
warns and skips the watcher instead of dying on mkdir under errexit.
- The compose example lists the /romm/sync mount the sync features need.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(sync): cover reading back and clearing buffered PSP files
Addresses Greptile's review on #5189.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(sync): apply code-review findings to PSP pending buffer
Remove the emptied psp_pending folder after a merge, define the sync
folder path once in init, update the architecture doc's PSP and blob
locations, and drop a stale .gitignore entry.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* refactor(sync): apply simplify findings to PSP pending cleanup
Clear the buffered folder with remove_directory, let the startup check
own creating the sync folder, and reword the test fixture docstring.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(sync): cap buffered PSP files and drop them on delete
Buffered files for an unresolved save folder now count against the
bundle limits, so a folder can't fill the assets share and then fail
every merge once it resolves. A DELETE also removes the buffered copy,
so a deleted file isn't merged back when the folder resolves.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(docker): check the sync folder for push-pull sync too
ENABLE_SYNC_PUSH_PULL keeps SSH keys and device saves under /romm/sync
as well, so an unwritable folder now disables it with the watcher and
warns at boot instead of failing when the task runs.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(docker): strip whitespace from env vars like the backend does
The backend strips every variable it reads, while the init script and
nginx templates used raw values, so a padded ROMM_TMP_PATH sent nginx's
/cache/ alias somewhere the backend never writes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* chore(config): drop the CACHE_BASE_PATH comment
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(docker): say which backend config strips env whitespace
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* revert(docker): drop the entrypoint env whitespace trimming
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(sync): apply pr-ready code-review findings
Gate push-pull on its SSH keys path rather than a writable sync folder,
accept the same truthy values as the backend, and clear only the merged
PSP pending files so another worker's buffered file survives.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* refactor: apply pr-ready simplify findings
Share one truthy pattern across init's flag checks (the watcher gates
now accept the same values as the backend), disable gunicorn's unused
control socket instead of placing it, derive the converts redirect from
its own cache path, and factor the unknown PSP folder in tests.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(docker): apply pr-ready humanizer pass to the sync mount note
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(fs): create handler base folders on first write, skip leftover temp files
FSHandler no longer mkdirs its base path when constructed, so a module-level
handler rooted at an unmounted or unwritable folder can't take down boot;
every write path already creates its parent folders. Blob listings skip
.romm_tmp_ files a crashed write left behind, so they are never merged into
a PSP bundle or advertised in the sync manifest. The prefix now lives in one
TEMP_FILE_PREFIX constant.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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>
- 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>
- 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>
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>