Game saves: an empty configuration id no longer deletes the other configurations' saves #209

Manually merged
github merged 1 commit from gh-pr/209/head into gh-pr/209/base 2026-11-26 03:54:49 +00:00
Owner

@⁠Maraco91 on GitHub · 2026-11-24 01:27 UTC · original
Maraco91:xgamesave/empty-configuration-id → main · +30 −2 · 1 files · 1 commits · merged 2026-11-24 07:56 UTC

What

XGameSaveInitializeProvider with an empty configuration id ("", not null) deletes the saves of every other configuration of that user.

Provider::open builds the provider's folder as <saves>\<xuid>\<file_name(config)>, with "default" for a null id. For "" the file name is empty, so the folder is <saves>\<xuid> itself: the folder the configurations' own folders are in. open then calls containers(&root) to convert containers of the old layout, which it recognises as folders with no ~ and no dot in their name. A configuration's folder (default, a GUID, ..) is exactly that, so for each one migrate:

  1. finds no blob files in it (its entries are container folders, which do not read as files),
  2. commits an empty container named after the configuration,
  3. remove_dir_alls the configuration's folder, with every container in it.

An empty id is now treated like a null one: the default configuration. Nothing else changes; named configurations get the folders they had.

What I do not know: what the console's runtime answers for "" (it may refuse it). Treating it as the default keeps the call working, as it does today, and I preferred that to turning a success into an error on a guess; if the right answer is a refusal, the same line can return it. I have not seen a title pass "" (I have no game files). The cost when one does is the user's saves, which is why I think it is worth closing.

Tested

Windows 11 Pro 10.0.26200, rustc 1.98.1 (x86_64-pc-windows-msvc), no game data, no GPU involved. Saves go to a temporary folder.

New unit test an_empty_configuration_id_is_the_default_one: writes a save under configuration scid, opens a provider with "", and checks that scid's folder and save are still there and that the provider is the default one's (same folder as a null id). Controls: the default, scid and a third configuration stay apart (the new ones are empty, scid's save is unchanged after all three were opened).

  • main (d2a4bae) + the test only: cargo test -p victory-hle --lib an_empty_configuration fails: another configuration's saves are gone (the folder was removed).
  • with the fix: cargo test -p victory-hle --lib xgamesave::: 6 passed, 0 failed (the 5 existing ones, among them the old-layout conversion and the kill-at-any-step test, and the new one).
  • cargo clippy -p victory-hle --tests: nothing in xgamesave.rs. rustfmt --check: nothing in the lines changed (the file has existing differences elsewhere).
  • cargo xtask policy: 151 files ok.

Not tested: a title run.

AI-assisted (Claude Code); the tests above were run on the machine described.

🤖 Generated with Claude Code

**@⁠Maraco91** on GitHub · 2026-11-24 01:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/209) `Maraco91:xgamesave/empty-configuration-id` → `main` · +30 −2 · 1 files · 1 commits · merged 2026-11-24 07:56 UTC ## What `XGameSaveInitializeProvider` with an empty configuration id (`""`, not null) deletes the saves of every other configuration of that user. `Provider::open` builds the provider's folder as `<saves>\<xuid>\<file_name(config)>`, with `"default"` for a null id. For `""` the file name is empty, so the folder is `<saves>\<xuid>` itself: the folder the configurations' own folders are in. `open` then calls `containers(&root)` to convert containers of the old layout, which it recognises as folders with no `~` and no dot in their name. A configuration's folder (`default`, a GUID, ..) is exactly that, so for each one `migrate`: 1. finds no blob files in it (its entries are container folders, which do not read as files), 2. commits an empty container named after the configuration, 3. `remove_dir_all`s the configuration's folder, with every container in it. An empty id is now treated like a null one: the default configuration. Nothing else changes; named configurations get the folders they had. What I do not know: what the console's runtime answers for `""` (it may refuse it). Treating it as the default keeps the call working, as it does today, and I preferred that to turning a success into an error on a guess; if the right answer is a refusal, the same line can return it. I have not seen a title pass `""` (I have no game files). The cost when one does is the user's saves, which is why I think it is worth closing. ## Tested Windows 11 Pro 10.0.26200, rustc 1.98.1 (`x86_64-pc-windows-msvc`), no game data, no GPU involved. Saves go to a temporary folder. New unit test `an_empty_configuration_id_is_the_default_one`: writes a save under configuration `scid`, opens a provider with `""`, and checks that `scid`'s folder and save are still there and that the provider is the default one's (same folder as a null id). Controls: the default, `scid` and a third configuration stay apart (the new ones are empty, `scid`'s save is unchanged after all three were opened). - `main` (d2a4bae) + the test only: `cargo test -p victory-hle --lib an_empty_configuration` **fails**: `another configuration's saves are gone` (the folder was removed). - with the fix: `cargo test -p victory-hle --lib xgamesave::`: **6 passed, 0 failed** (the 5 existing ones, among them the old-layout conversion and the kill-at-any-step test, and the new one). - `cargo clippy -p victory-hle --tests`: nothing in `xgamesave.rs`. `rustfmt --check`: nothing in the lines changed (the file has existing differences elsewhere). - `cargo xtask policy`: 151 files ok. Not tested: a title run. AI-assisted (Claude Code); the tests above were run on the machine described. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A provider's folder is the user's folder plus the configuration id as a
file name. An empty id gave the user's folder itself, where the other
configurations' folders are. Opening the provider converts containers
of the old layout, which are folders without a `~` or a dot in their
name, as a configuration's folder is: each was taken for one, an empty
container was committed in its place and the folder was removed with
every save in it.

An empty id is now treated as no id (the default configuration).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:54:48 +00:00
github manually merged commit c88b7ac1cc into gh-pr/209/base 2026-11-26 03:54:49 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 04:57 UTC · original

Thanks @⁠Maraco91 for covering the empty configuration ID against an existing named save.

I tested commit c88b7ac1cce4d2d3b12d761bd66632f65a5a6e23 with:

cargo test --locked -p victory-hle --lib an_empty_configuration_id_is_the_default_one -- --test-threads=1

The targeted test passed (1 passed, 0 failed; 86 filtered). It creates data under a named scid configuration, opens a provider with an empty ID and one with no ID, then verifies the empty ID resolves to the default root without deleting the scid data. It also checks that the default remains separate from named configurations and that opening another named configuration does not disturb the saved data.

The test at this commit uses a temporary directory and the local provider implementation; it does not exercise a real title or Xbox service integration.

**@⁠jeremygold02** on GitHub · 2026-11-24 04:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/209#issuecomment-7122494925) Thanks @⁠Maraco91 for covering the empty configuration ID against an existing named save. I tested commit `c88b7ac1cce4d2d3b12d761bd66632f65a5a6e23` with: ``` cargo test --locked -p victory-hle --lib an_empty_configuration_id_is_the_default_one -- --test-threads=1 ``` The targeted test passed (1 passed, 0 failed; 86 filtered). It creates data under a named `scid` configuration, opens a provider with an empty ID and one with no ID, then verifies the empty ID resolves to the default root without deleting the `scid` data. It also checks that the default remains separate from named configurations and that opening another named configuration does not disturb the saved data. [The test at this commit](https://github.com/Marvisak/VIctory/blob/c88b7ac1cce4d2d3b12d761bd66632f65a5a6e23/crates/victory-hle/src/modules/xgamesave.rs#L1118) uses a temporary directory and the local provider implementation; it does not exercise a real title or Xbox service integration.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!209
No description provided.