WIP: feat(saves): the game backs its saves up and restores them into an empty folder #1428
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
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/Longshot!1428
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:feat/save-backups"
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?
Type: feat · Risk: medium · Tested on: Linux, game-free only · Needs: Windows and Linux, a start and a save, in the game
Why
A game started without the launcher keeps its saves in the game folder (
user\save), and the launcher's builds before the shared folder did too: uninstalling to update, building into a new folder or deleting the old one took them along. A deleted or broken save in the shared folder is gone as well. The launcher backs saves up only before it copies over them.Ported from Hookshot
0e264748(NotRexed):git.notrexed.dev/Hookshot/Hookshot@0e264748afThe tracker was searched for "save backup", "lost saves" and
HOS_SAVE_BACKUP: no pull request or issue does this. Nearby open work is other save tools: #1397 (the save script's Windows default), #1401 and #1403 (editing and sharing saves).How to reproduce
Seen on: Hookshot's players, who lost saves updating. Not run on Longshot.
Settings and switches: defaults.
Steps: start the game directly (no launcher) from a game folder, save, delete the game folder, build into a new one, start.
Expected: the saves are there.
Actual: on main the new folder starts with no saves.
What changed
host/save_backup.c(new) copies the save folder into the folder the launcher andscripts/longshot_saves.pyalready back up to (docs/saves.md):%LOCALAPPDATA%\Longshot\oot-save-backupson Windows,$XDG_DATA_HOME/oot-save-backupson Linux. A backup isgame-<YYYYmmdd-HHMMSS>holding a copy of the save folder, the launcher's own layout, so it goes back the same way. One is made at each start and after a save mount'snn::fs::Commit(at most every 20 s), only when something is newer than the last; the 20 newestgame-folders stay, and the launcher's and the script's are never touched. A start whose save folder holds no file takes the newest backup in before the game reads its saves, and logs it; a folder with saves is never touched.Unlike Hookshot, only the player's own saves are backed up and restored: the user folder the game picks itself, or on Windows the launcher's
%APPDATA%\Longshot. A run given another--user(a test's, the farm's, a second profile) and a scripted run (HOS_HEADLESS,HOS_CONTROL) make and restore none, so a Test Farm run "from a new save" is never filled with a volunteer's saves, and a test's saves never become the newest backup.HOS_SAVE_BACKUPS=<folder>names another place and lifts that rule (a portable launcher could pass its own folder);HOS_SAVE_BACKUP=0andHOS_SAVE_RESTORE=0turn them off.host/save_backup.c,host/save_backup.h(new);host/hos_main.ccallshos_save_backup_startright after the user folder is made, knowing whether--usernamed it;host/nn_fs.c'sCommitbacks up after a save mount's commit.tests/test_save_backup.py(new, from Hookshot's) buildssave_backup.cas it is (on Linux overhost/posix/win32_posix.c's file functions) and runs it in a temporary folder.docs/saves.md(the game's own backups),docs/development.md(the three switches).Measurements
Verdict: the game-free check fails before the feature and passes here. Nothing in the game has been measured.
Hardware: Linux, no game run.
Scene: none.
Method:
python -I -B tests/test_save_backup.pyon the test commit and on this head.How to reproduce: check out
ad9f34fb(the test alone, on main544229a2) and run the command; then this head.544229a2plus the test @ad9f34fbed8cbd38tests/test_save_backup.pypython -I -B tests/run_all.pyon this head (Linux, 16 at once): 602 passed, 39 failed, 81 skipped (no Vulkan or SPIR-V headers here). The failures are the onesmain544229a2has on this PC, excepttest_appimage_package_retryandtest_compile_stops_on_exception, which failed under the full run's load and pass alone on this head.Flags and settings
HOS_SAVE_BACKUP=0game-<time>copy at start and after a saveHOS_SAVE_RESTORE=0HOS_SAVE_BACKUPS--userTesting
Tested: Linux, game-free. The new check (backups made only when something is newer, the 20 newest kept and the launcher's left, an empty folder restored and a full one untouched, the switches, and no backups for another
--user,HOS_HEADLESSorHOS_CONTROL); the checks that readnn_fs.cand the save and UTF-8 path checks.Not tested: the game, Windows, a host build (
a64_suyu.his not on this PC). Opened with--forcebecause Joey asked; this PC is not running the game.Must be tested:
game-<time>folder in%LOCALAPPDATA%\Longshot\oot-save-backupsand the log linesaves: backed up N files of .... Then empty the save folder and start:saves: none in ...: the newest backup (...) copied in, and the save loads.~/.local/share/oot-save-backups.--user: no backup line.Risks
What could break: a player who empties the save folder on purpose to start over gets the newest backup back at the next start (
HOS_SAVE_RESTORE=0, or delete the backups too). Each backup copies the whole save folder (a few MB) at most every 20 s while the game saves. On Windows the portable launcher passes its own--user, so its saves get no backups unless it setsHOS_SAVE_BACKUPS.Turning it off:
HOS_SAVE_BACKUP=0,HOS_SAVE_RESTORE=0.Compatibility: nothing in the save files or options. The backups folder is shared with the launcher; the game only writes and prunes its own
game-folders.MKWVK_API_VERSIONis unchanged.Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: Testing's Tested names only game-free checks, and the change touches host/ with no in-game run yet.
in Risks. Not ticked yet: Risks names a save copy every 20 s and Measurements says nothing in the game is measured.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). The failures also fail onmainhere; two failed only under load.third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here.save_backup.ccompiles in the check on Linux over the shim's file functions, and uses the A file functions, UTF-8 under the game's manifest.@Beanstalk Windows and Linux, any GPU, started the way a player starts it (the launcher, or the game folder with no --user; not a scripted run, since HOS_HEADLESS and HOS_CONTROL turn the backups off). Three steps: (1) start and save in the game; expected a
game-<time>folder in the backups folder (%LOCALAPPDATA%\Longshot\oot-save-backupson Windows,~/.local/share/oot-save-backupson Linux) and the log linesaves: backed up N files of .... (2) Close, empty the save folder, start again; expectedsaves: none in ...: the newest backup (...) copied in, and the save from step 1 loads. (3) A run with its own --user folder: nosaves: backed upline. Not run in the game yet; Joey asked for this pull request so the farm can take that run.@TrashPanda only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).
**Not testable by hand:**line saying why and what stands in for it. Then tick it.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.