fix: track save revisions with SaveDataId and CommitId - #9
Open
Margok1987 wants to merge 5 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the automatic-backup change detector's mounted-file
st_mtimeheuristic with Horizon save metadata:AccountUid + TitleIDSaveDataId + CommitIdfromFsSaveDataInfo/FsSaveDataExtraData.syncstate-v2The server protocol, restore path, account selection and background-service control flow are unchanged.
Why
On real Switch hardware the current detector repeatedly observed mounted save files with
st_mtime == 0.The existing implementation treats a zero timestamp as changed, so an unchanged save is uploaded again on every check.
Hardware A/B/C measurements on two independent account/title saves showed:
0in all samplesSaveDataId: stable across unchanged and changed savesCommitId: stable across immediate unchanged A/B samplesCommitId: changed after an actual in-game save B/CThis provides a Horizon-native revision token without depending on POSIX timestamps from the mounted save filesystem.
State semantics
.syncstate-v2stores one entry per account/title:The legacy
.syncstateis not trusted or migrated. The first run after upgrading therefore intentionally creates one fresh baseline backup per account/title.State is only an optimization. Any metadata failure, missing or ambiguous record, corrupt state, or state-write failure leaves the title eligible for another backup.
Upload race handling
For every selected title the client captures the revision that caused it to be considered changed.
After archive + upload it reads the revision again:
This prevents a save committed during an upload from being incorrectly marked as already backed up.
Validation
Host-side tests covered:
Result:
ALL_TESTS_PASS.Hardware-tested source snapshot:
7cbd4af97938fff5a4cf4f85a3ec3106c3451108328106474804baa0046e2dace86be0a569889307b25cbc99575817c932c5aab48e6458a633590101793e334267d600b7c9c1087e6d213186e19980123b0b78af1b6c678cda1Hardware acceptance confirmed:
The current PR head only removes the temporary candidate-build workflow after that test. The production source files are unchanged from the hardware-tested snapshot.
Scope
Changed production files only:
client/source/sync.cppclient/source/sync.hppNo server/database/API changes. No restore behavior changes.