Repository navigation
Cloud saves: a game's sync notes belong to the account they were made under - #579
Merged
Merged
Conversation
…count without an id keeps its notes
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.
Follows up #405, which scopes only the in-memory "newer save" badge cache to the sign-in. The saved per-game cloud notes (
saves::State, each game'sstate.json) still carried over to the next account:upload_pending/retry_pending_later, and uploaded there if B had no save for the game;should_restoreused A's sync point (a backup copy was kept).What changes
state.jsonnow names the sign-in its cloud fields belong to ("cloud_scope": "recompstore:<uid>", the account'suid). The check is insaves::state/saves::set_state, so every reader and writer goes through it:sync_status(Saves tab and Big Picture),upload_pending/retry_pending_later(viapending_copy),after_session,saves_upload_now,saves_restore,incoming,should_restore/check_saves,finish_open_sessions.last_hash,after_play) stay, so local change detection still works. An upload queued under A is never sent for B.read_under). An upload or download that ends after the account changed isn't marked as synced for the new account (still_signed_in_as). A download still records the save it put in place aslast_hash.upload_oneloads the account once, before it reads the note, and passes it down toupload_copy. So a switch mid-request can't send A's copy with B's token; that upload just stops, the log says why, and the copy waits for B's own sync.set_state_saves_replaced). Restoring an older save while signed out, or as B, doesn't let A's superseded copy go up when A signs in again.account.jsononly (cloud::account_uid). The sealed token isn't opened, so the frequent state reads never reach Windows' Credential Manager.Old state.json files (no
cloud_scope)Rule: an old note belongs to the account that is signed in when this version first reads it, and it gets stamped with that account then. An old note read while nobody is signed in belongs to no account: its cloud fields are dropped and the local ones kept.
Why: switching accounts was rare, so a note made under the account that's signed in at update time is almost always that account's. Treating every old note as unknown would drop every player's queue and sync point at the update. Their next sync would then turn into a "which save?" question, or a queued copy would be held as a conflict. With nobody signed in, nobody can say who made the note, so nothing pending from it is sent without the player.
finish_open_sessionsreads every game's note at startup, so the stamping happens right away on the first start.Other PRs
state.jsonwith the same key and format (cloud_scope,"<provider>:<identity>"), so notes written by either PR read correctly in the other. When Add Google Drive as a cloud save provider #228 is rebased,scope_nowhere should becomesave_provider::scope, and Add Google Drive as a cloud save provider #228'sforget_cloudis the same as this one. One difference: Add Google Drive as a cloud save provider #228 adopts an old note even when signed out (its scope is thenrecompstore:). This PR doesn't, for the reason above. Add Google Drive as a cloud save provider #228 should take this rule when rebased.PEEKED,store_locked,saves_info,saves_peek). No overlap in logic. The textual overlap is next tostore_locked, where Scope cloud-save status cache to the current sign-in #405 adds a hook and this PR addsaccount_uidbelowsigned_in.folder_freechecks and tests inchild_retry_tests. The new tests here go at the end of that module to stay clear of them.No new player-facing text: the only new strings are trail notes in the log.
Tests
18 new behaviour tests write
account.jsondirectly (cloud::sign_in_for_tests) and only touch state files. None of them reaches the Credential Manager.pending_copyafter switching to B;last_hashstays;incoming/should_restore;still_signed_in_asturns false once the account changes.Existing tests that store cloud fields now sign in first.
cargo teston windows-vm: 1117 passed, 0 failed, 1 ignoredcargo teston bazzite-kde (Fedora toolbox): 1217 passed, 0 failed, 1 ignorednode --test tests/*.test.cjson bazzite-kde: 947 passed, 33 failed. Plain upstream/main fails the same 33 on that VM, and this PR changes no JS