Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

A restore that cannot first copy the save changes nothing - #163

Open
GeneBO98 wants to merge 3 commits into
Liquid-co:dev-publicfrom
GeneBO98:fix/restore-safety
Open

GeneBO98 wants to merge 3 commits into
Liquid-co:dev-publicfrom
GeneBO98:fix/restore-safety

Conversation

@GeneBO98

Copy link
Copy Markdown
Contributor

Restoring a snapshot, restoring a single file, and "keep the other device's version" each take a safety snapshot before replacing the save. Each one carried on when that copy failed. A full disk, a locked file or a database error then emptied or overwrote the save with nothing to go back to. Branch switching already refuses in that case; this does the same for the other three.

Changes

  • Restore (snapshot.Restore): if the safety copy, or the temporary copy of the archive kept safe from pruning, can't be made, the restore stops with "nothing was changed".
  • Restore checks every save location. It used to take its safety copy only when the main folder had files, then empty every location. A mods or settings folder holding the only work was cleared without a copy. The check is now anySaveContent, shared with SwitchBranch.
  • Keep-remote (conflict.go): stops instead of overwriting when the copy of this device's version fails. The conflict stays open.
  • Single-file restore (handleRestoreFile / extractSingleFile):
    • stops when the safety copy fails
    • no longer truncates the file in place: it writes to <file> + delta.TmpSuffix and replaces the file through the new delta.ReplaceFile, the same retrying, owntouch-marked replace a sync uses
  • No cut-short files in snapshots: a file whose read failed after its zip entry had started was reported as skipped, but the partial entry stayed in the archive, and a restore put back the short file. That now fails the archive (errEntryCutShort).

Tests (each fails on dev-public without the change):

  • TestRestore_StopsWhenTheSafetyCopyFails
  • TestRestore_SafetyCopyCoversOtherLocations
  • TestCreate_RefusesAFileCutShort
  • TestConflict_KeepRemoteStopsWhenTheSafetyCopyFails
  • TestExtractSingleFile_FailingPartWayLeavesTheFile (on dev-public the damaged entry overwrites the save, then the call reports an error)

Also: TestRestore_MainFolderDeleted.

Draft #31 also touches incomplete snapshots, in a different way; this PR doesn't depend on it.

🤖 Generated with Claude Code

GeneBO98 and others added 2 commits November 18, 2026 13:20
Restoring a snapshot, restoring a single file, and keeping the other
device's version of a conflicted save each take a safety snapshot of the
save they are about to replace, and each carried on when that copy could
not be made. A full disk, a locked file or a database error then emptied
or overwrote the save with nothing to go back to. Switching branches
already refused in that case; these now do the same.

Restore also took its safety copy only when the main save folder held
something, then emptied every save location. A settings or mods folder
holding the only work was cleared without a copy. The check now covers
every location, shared with branch switching.

Two ways a short file could stand in for a save are closed as well:

- A file whose read failed part-way into an archive was reported as
  skipped, but the zip entry already started stayed in it, cut short. A
  restore put that short file back. The archive is now abandoned instead.
- Restoring one file truncated it in place before copying, so a copy that
  failed part-way left it cut short. It is now written beside the file and
  renamed over it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… replace

The single-file restore now writes to the file's name plus
delta.TmpSuffix, which manifests and snapshots already leave out, and
replaces the file through delta.ReplaceFile. That retries while
antivirus holds the file, clears a read-only flag, and marks the change
as OpenSave's own for the watcher. Before, a temporary name of its own
in the save folder could have been picked up by a snapshot or sync, and
a single failed rename on Windows failed the restore.

Tests: a damaged entry leaves the live file untouched with no temporary
file behind (on the previous code it overwrote the save, then reported
the error), and a restore over a deleted main save folder still works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

@GeneBO98 is attempting to deploy a commit to the sivadaboi's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Omar-VF

Omar-VF commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Reviewed and tested, looks good. One small thing: in snapshot.go, anySaveContent went in between savePathHasContent and its doc comment. The old comment now sits above the new function, and savePathHasContent has none. Could you move that comment back above savePathHasContent?

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GeneBO98

Copy link
Copy Markdown
Contributor Author

Thanks, done in d8f7e97: the comment is back above savePathHasContent, and anySaveContent keeps its own.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants