feat(saves): sync saves between devices through a folder the player picks #275
No reviewers
Labels
No labels
area/build
area/install
area/mods
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!275
Loading…
Reference in a new issue
No description provided.
Delete branch "dukenheimer/LongshotLauncher:feat/save-sync"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Players with a PC and a Steam Deck have no way to keep one adventure on both: they copy saves by hand or play two. This adds an opt-in sync through a folder both devices already reach (a OneDrive, Dropbox, Google Drive or Nextcloud folder, or a network share), with no server and no account of ours.
What changed
PadInput.PastTheFold), and a page with no main button starts on its first control rather than its footer's Release notes. In the TV view a drag on the touchscreen scrolls the page (Gaming Mode hands the window the touchscreen as a mouse).docs/controller.mdsays so.--play, which Steam runs on the Deck): when only the sync folder's save changed since this device and the folder last agreed, or this device has none, it comes in through the existing whole-folder import (SaveArchive.ImportWhole), this device's backed up first (sync-local-<stamp>). When only this device's changed, it goes out. In the window this runs off the UI thread.--play, and after its window is closed, with the home released so it can open again) and sends this device's save, unless the sync was turned off or moved meanwhile.save-sync.jsonin the launcher's home, the content it last agreed on with the folder. Each manifest lists the contents its save was made from, so two saves sent apart while a cloud client lagged are a conflict and never mistaken for newer.SyncConflictView); the choice is bound to the save shown, and a newer one is asked about again. Under--play, both before and after the game, this device's is kept and the folder's is set aside assync-other-<stamp>. The window says so once when it next opens. Both kinds of backup are listed in Restore from a backup… (BackupKind.Sync).Longshot saves.jsonand the zip it names,Longshot saves sync-<id>.zip(the same whole-folder zip as Export saves… > A .zip file…), plusLongshot saves.lockwhile a device writes. Each write uses a new zip name: the zip is built and verified in temp (it unpacks whole to exactly the manifest's content), copied in, and the manifest is re-read and the lock re-checked before an atomic rename replaces it. Only then is the old zip deleted. A cut-short write always leaves the manifest naming a zip that exists. The zip is copied out and checked before unpacking, so OneDrive Files On-Demand placeholders work. The player's ownLongshot saves <date>.zipis never touched.save-work, the game's working copy, never syncs: it is left out of the zip and the content hash at any depth, and an import keeps the local one where it was. The save folder stays a plain folder where it always was: nothing is linked into the cloud folder, so backup or cloud tools that walk the save folder see plain files (the concern behind #258). This doesn't fix #258 itself: GoodSync there trips over the junction each Windows build'suser\savealready is, which this PR doesn't touch.SaveArchive:ExportSavegainsleaveOut, andImportWholegainsbackupNameandkeepLocal. Export now also leaves out what a file manager adds (desktop.ini,Thumbs.db,.DS_Store), which import already ignored. A folder holding only those, or only links, goes in as an empty folder, so a zip unpacks to the folder as the hash sees it.rclone configsign-in for OneDrive, Google Drive and Dropbox, WebDAV with an app password for Nextcloud, and asystemctl --usermount service with the tuned options); Syncthing as the no-cloud option; and how to switch services. OneDrive, Google Drive and Dropbox have no SteamOS app.Merged with main
--playarrival is what starts the game, so it waits for the game and sends the save after it.StartFolderreturns no game when it routed.Residual risks (known, documented)
CONTRIBUTING's rule
"No saves leave your PC" is about contributors and this repository. Here the player's own saves go only to a folder the player picked, and only once they turn the sync on. Maintainers may want to say so in the privacy page.
Tests
tests/launcher_core/SaveSyncChecks.cs(new, two made-up devices, fake saves) covers:save-workbeside the save, in a profile and in a slot, including a slot the other device dropped;python -I tests/test_launcher_core.py: 2858 checks passed (after merging main, up to #276) on Linux (WSL Ubuntu 24.04, .NET SDK 10.0.404), translations check clean. On Windows the new checks pass too. Two suites,SavesChecks' link check andSteamChecks, fail on that PC on unmodifiedmainas well, so they were skipped there (2360 passed).tests/launcher_app(the app-level checks, with the wait for a game handed over to another process): pass.tests/test_release.pyat.tooling-rev: 42 tests OK.dotnet build LongshotLauncher.slnx: 0 warnings, 0 errors.Tested by hand
Dev builds on Brett's PC (Windows 11) and Steam Deck (SteamOS, Game Mode via Steam), through his OneDrive: the PC through the OneDrive client, the Deck through an rclone mount of the same folder (as in the new docs note).
sync-local-20261124-202524).--playnow wait for the started process and then for no game running (LauncherService.WaitForGameEnd, checked intests/launcher_app).Screenshots
The Saves page with the sync on:
The TV view (Steam's Gaming Mode), Sync now reached with the d-pad:
Both from
tools/screenshots(saves-sync,tv-saves); the conflict dialog's is still to come.Measurements
Off by default: nothing changes for a player who doesn't turn it on. When on, Play waits for:
Possibly related, for context:
WIP: feat(saves): sync saves between devices through a folder the player picksto feat(saves): sync saves between devices through a folder the player picksFollow-up: a built-in cloud account (bundled rclone, no mount or setup on the Deck) is proposed in #277.
@review
Recommendation: Request changes. The sync can replace a save while a game or another save operation is using it, and an unmounted folder can be mistaken for an empty shared folder. The conflict history can also classify a divergent save as a descendant and replace it without asking.
Adds opt-in save synchronization through a player-selected folder, conflict handling, backups, controller scrolling and setup guidance. It makes moving an adventure between devices easier, but the current coordination and ancestry checks can put progress at risk.
Blocking (4): must change before merging.
Core/SaveSync.cs:195: The gather lock does not exclude the game or the other save-writing operations for the duration of an import. (more on the line) Do: Coordinate game startup and every operation that changes the shared save with the same cross-process lock, holding it through the save swap or edit and through the game-start decision. Recheck running state after acquiring it.Core/SaveSync.cs:210: A full history is treated as proof of ancestry even when it contains no common save. (more on the line) Do: Treat missing ancestry as unknown and ask about the conflict, or use an ancestry representation that can prove the relationship beyond the history cap.Core/SaveSync.cs:175: Clearing a parked-conflict notice rewrites the sync state without the lock used by sync operations. (more on the line) Do: Read, clear and write the parked fields under the same cross-process lock as every other state update.Core/SaveSync.cs:191: An existing empty mount point is treated as a reachable, new sync folder. (more on the line) Do: Detect an unavailable configured mount before treating an empty directory as a new shared folder, and report it as unreachable. Preserve a marker or equivalent identity that also distinguishes a previously used folder from an empty replacement.@fixcan do L1, L2, L3 and L4.Checks: Still running:
CI / Conventional Commit title (pull_request),CI / Compile and test (pull_request).More: does it help, other systems, switches, what was read
Does it help: Unproven as a reliable sync: the author reports a successful Windows PC–Steam Deck OneDrive round trip and automated checks, but the cases in the review are not covered by those runs. This is not a performance change.
Other systems: The sync affects save imports, the save editor, simultaneous launcher processes, Steam's unattended launch, network shares and asynchronously replicated cloud folders on Windows and Linux. The reported round trip covers OneDrive and rclone; it does not cover the coordination and divergent-history cases below.
Switches: Sync saves through a folder is added, off by default, with a remembered folder. Opt-in is appropriate, but the enabled behavior needs the fixes below.
Reviewed:
5c0b7eca4cagainst3af691ed6d: Read AGENTS.md and CONTRIBUTING.md; the named review checklist and pull request template are absent. Read the sync implementation, archive changes, launch and UI diffs, sync checks, and relevant save and setup documentation; skimmed the remaining changed UI, documentation, test and screenshot changes. The larger existing files and generated or translation content were not read in full.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run, as requested. The author reports core and app checks and a Windows–Steam Deck OneDrive round trip; CI was still running.
Overlaps and merge order: The author identifies #277 as a follow-up for built-in cloud accounts; no other overlap was established from the supplied context.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +172,4 @@/// The sync-folder save a start with no window set aside in a conflict (unattended), said once: cleared as it is readpublic static (string Backup, string Device, DateTime Written)? TakeParked(string statePath){var state = ReadState(statePath);L3 (blocking): Clearing a parked-conflict notice rewrites the sync state without the lock used by sync operations.
When: On opening the window, TakeParked can read the old state while a simultaneous unattended sync or Sync now updates Base and writes the state under the gather lock. TakeParked can then write its stale copy back, losing the new agreement or parked notice and causing subsequent sync decisions to use the wrong base.
Do: Read, clear and write the parked fields under the same cross-process lock as every other state update.
@ -0,0 +188,4 @@{try{if (!Directory.Exists(p.Folder)) return new(SyncOutcome.Unreachable, p.Folder);L4 (blocking): An existing empty mount point is treated as a reachable, new sync folder.
When: With the documented Deck rclone service stopped, ~/LongshotSync still exists as an empty local directory. The launcher exports there and records an agreement; when the mount returns, the local files are hidden and the device has reported a sync that never reached the other device.
Do: Detect an unavailable configured mount before treating an empty directory as a new shared folder, and report it as unreachable. Preserve a marker or equivalent identity that also distinguishes a previously used folder from an empty replacement.
@ -0,0 +192,4 @@if ((p.Running ?? (() => Saves.Running(Platforms.Current)))() is { Count: > 0 } busy)return new(SyncOutcome.Busy, string.Join(" and ", busy) + " is running.");FileStream held;try { held = Saves.HoldGatherLock(p.Env); }L1 (blocking): The gather lock does not exclude the game or the other save-writing operations for the duration of an import.
When: A Sync now import can already be copying when Play's separate sync waits ten seconds for the gather lock and returns Busy; Play then starts the game. The first import can pass its running check before the game starts and subsequently swap the save folder under the running game. The UI's SyncRunning check also is only a check, and does not cover another launcher process or Progress edits.
Do: Coordinate game startup and every operation that changes the shared save with the same cross-process lock, holding it through the save swap or edit and through the game-start decision. Recheck running state after acquiring it.
@ -0,0 +207,4 @@/// The sync folder's save was made from base, or from a save made from it (base null: this device never agreed with it). A/// History as long as one is kept may have lost base: unknown, never taken as a conflict against an unchanged devicestatic bool Follows(SaveSyncManifest m, string? @base) =>@base != null && m.History is { } h && (h.Contains(@base) || h.Count >= Kept);L2 (blocking): A full history is treated as proof of ancestry even when it contains no common save.
When: A device last agreed on save A, then published its own branch B while a cloud client lagged. If a different branch reaches 1,000 history entries without containing B, that device's unchanged local B is treated as behind and Pull imports the other branch without a conflict prompt.
Do: Treat missing ancestry as unknown and ask about the conflict, or use an ancestry representation that can prove the relationship beyond the history cap.
Please re-implement this on the new launcher!
Ideally, this should be in the settings under game with other paths. It should be a checkbox like 'customize saves directory' which when enable, can select new location, similar to the other paths. It should move the saves to new dir too like other stuff
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.