Preserve the last complete save during XGameSave recovery #4273

Open
github-bot wants to merge 2 commits from github-bot/gh-4272 into main AGit
Owner

@⁠invismann on GitHub · 2026-11-30 18:01 UTC · original
invismann:fix/xgamesave-recovery → main · +166 −33 · 1 files · 2 commits · open

Split from #4255.

What it changes

  • Abort legacy save migration when reading a blob fails, preserving the original container.
  • Select the newest complete committed version before removing older versions. Clean up only canonical staging directories such as v2.new.

Based on towiice's 034cb3de6 and lgtlgt0015-code's 7e9f3a028 and 2e2ca139f.

How it was tested

  • Before: All three save regressions failed on 84bd61e2c with the tests applied. The cases cover an unreadable legacy blob, a newer version with a missing or invalid blob file, and noncanonical staging directory names.

  • After: The Windows victory-hle modules::xgamesave:: suite passed on this branch, including all three regressions. The fixtures use temporary directories and synthetic blobs. The asset policy passed for the save commit.

  • Startup smoke: The combined branch in #4255 ran on Windows with an RTX 4090, Series X at 2560×1440 SDR, and DLSS, frame generation, and hardware ray tracing disabled. It reached at least 1,024 presented frames.

  • CI baseline: The workspace Clippy run on #4255 failed on existing warnings in the shader and GPU crates. CI log

Checked for overlap

  • Searched open PRs for save recovery and the affected module. #3657 reports enumeration errors and #3154 validates output pointers.
**@⁠invismann** on GitHub · 2026-11-30 18:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4272) `invismann:fix/xgamesave-recovery` → `main` · +166 −33 · 1 files · 2 commits · open Split from #4255. ## What it changes - Abort legacy save migration when reading a blob fails, preserving the original container. - Select the newest complete committed version before removing older versions. Clean up only canonical staging directories such as `v2.new`. Based on towiice's `034cb3de6` and lgtlgt0015-code's `7e9f3a028` and `2e2ca139f`. ## How it was tested - **Before:** All three save regressions failed on `84bd61e2c` with the tests applied. The cases cover an unreadable legacy blob, a newer version with a missing or invalid blob file, and noncanonical staging directory names. - **After:** The Windows `victory-hle` `modules::xgamesave::` suite passed on this branch, including all three regressions. The fixtures use temporary directories and synthetic blobs. The asset policy passed for the save commit. - **Startup smoke:** The combined branch in #4255 ran on Windows with an RTX 4090, Series X at 2560×1440 SDR, and DLSS, frame generation, and hardware ray tracing disabled. It reached at least 1,024 presented frames. - **CI baseline:** The workspace Clippy run on #4255 failed on existing warnings in the shader and GPU crates. [CI log](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46477555760/job/142055706089) ## Checked for overlap - [x] Searched open PRs for save recovery and the affected module. #3657 reports enumeration errors and #3154 validates output pointers.
Keep the legacy container if reading a blob fails. Prefer the last
complete committed version and prune only canonical staging directories.

Ported-from: avatarmanz/VIctory-7900XTX@034cb3de6 (towiice)
Ported-from: Belobug/VIctory-Belobug-AMD@7e9f3a028 (lgtlgt0015-code)
Ported-from: Belobug/VIctory-Belobug-AMD@2e2ca139f (lgtlgt0015-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 18:09:49 +00:00
Author
Owner

@⁠babuakhil on GitHub · 2026-11-30 18:30 UTC · original

Checked on Windows 11 (Rust 1.98.1, pinned), applied on current main (e1251c31); cherry-picks cleanly. cargo test -p victory-hle --lib xgamesave gives 19 passed, 0 failed, the three new cases among them. Not tested in the game.

The load and .new changes look right to me: a version missing a blob file now falls back to the one before it, and only v<N>.new directories are cleaned up, which is exactly what commit stages (format!("v{number}.new")).

For the migration change, I tried the case I'd expect most often on Windows: another program (a backup tool, a virus scanner) holding one blob of an old-layout save with no sharing, during one start only. A throwaway test (not part of this PR) used an old Player folder with Save Game Data = "progress" and Save Game Header = "header", the header opened with share_mode(0) during the first Provider::open, then released:

start 1 (header locked) start 2 (lock gone)
main the title sees Data=progress old folder gone; Header lost for good, Data=progress
this PR the title sees no save old folder gone; Data=progress, Header=header, complete
main, title saves a new Player in between sees Data=progress Data=fresh start
this PR, title saves a new Player in between sees no save old folder gone; only Data=fresh start; the old progress is deleted

So the PR fixes the silent loss of a blob (rows 1–2), but it opens a worse case (row 4). While migration is put off, the title finds no save, and a player who then starts a new game and saves makes current_named return a version, so the next start takes done and runs remove_dir_all(old) on a save that was never migrated. On main the title would have shown the progress and the player wouldn't have started over.

A small change would close it: when migration is put off, don't let a later version count as "done". For example, only remove old when the committed version came from the migration (a marker written in the same commit), or, when done but old still exists, rename it aside (Player.unmigrated) rather than delete it. A tracing::warn! naming the container when migration is put off would also tell the user why their save is missing for that run.

**@⁠babuakhil** on GitHub · 2026-11-30 18:30 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4272#issuecomment-7287948519) Checked on Windows 11 (Rust 1.98.1, pinned), applied on current `main` (`e1251c31`); cherry-picks cleanly. `cargo test -p victory-hle --lib xgamesave` gives 19 passed, 0 failed, the three new cases among them. Not tested in the game. The `load` and `.new` changes look right to me: a version missing a blob file now falls back to the one before it, and only `v<N>.new` directories are cleaned up, which is exactly what `commit` stages (`format!("v{number}.new")`). For the migration change, I tried the case I'd expect most often on Windows: another program (a backup tool, a virus scanner) holding one blob of an old-layout save with no sharing, during one start only. A throwaway test (not part of this PR) used an old `Player` folder with `Save Game Data` = "progress" and `Save Game Header` = "header", the header opened with `share_mode(0)` during the first `Provider::open`, then released: | | start 1 (header locked) | start 2 (lock gone) | |---|---|---| | `main` | the title sees `Data=progress` | old folder gone; **`Header` lost for good**, `Data=progress` | | this PR | the title sees **no save** | old folder gone; `Data=progress`, `Header=header`, complete | | `main`, title saves a new `Player` in between | sees `Data=progress` | `Data=fresh start` | | this PR, title saves a new `Player` in between | sees **no save** | old folder gone; **only `Data=fresh start`; the old progress is deleted** | So the PR fixes the silent loss of a blob (rows 1–2), but it opens a worse case (row 4). While migration is put off, the title finds no save, and a player who then starts a new game and saves makes `current_named` return a version, so the next start takes `done` and runs `remove_dir_all(old)` on a save that was never migrated. On `main` the title would have shown the progress and the player wouldn't have started over. A small change would close it: when migration is put off, don't let a later version count as "done". For example, only remove `old` when the committed version came from the migration (a marker written in the same commit), or, when `done` but `old` still exists, rename it aside (`Player.unmigrated`) rather than delete it. A `tracing::warn!` naming the container when migration is put off would also tell the user why their save is missing for that run.
A committed same-name version can appear after a locked legacy blob
delays migration. Keep the existing version active and move the legacy
directory into a numbered backup. Log the backup path.

Exercise a locked migration and a same-name save with a Windows sharing
violation. Verify both saves and any earlier backup keep their data.
github-bot force-pushed github-bot/gh-4272 from 49f339061e to 8ded1280c2 2026-12-01 06:09:24 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4273/head:github-bot/gh-4272'
git switch 'github-bot/gh-4272'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4272'
git switch 'github-bot/gh-4272'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4272'
git switch 'github-bot/gh-4272'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4272'
git switch 'main'
git merge --squash 'github-bot/gh-4272'
git switch 'main'
git merge --ff-only 'github-bot/gh-4272'
git switch 'main'
git merge 'github-bot/gh-4272'
git push origin 'main'
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/trustno1-coder--VIctory-NVIDIA!4273
No description provided.