Preserve the last complete save when a newer version is missing a blob #1981

Open
github-bot wants to merge 1 commit from github-bot/gh-1981 into main AGit
Owner

@⁠WerG0D on GitHub · 2026-11-25 02:15 UTC · original
WerG0D:fix/recover-incomplete-save → main · +58 −4 · 1 files · 1 commits · open

On Windows/NTFS, I reproduced a failed read that also deleted the last complete save version. On 940d32f, I created a complete v1 and a v2 whose manifest listed two blobs but whose directory contained only the first. Reading the slot removed v1 and then returned an error for the missing file.

This change checks that each numbered blob named by the manifest exists as a regular file before selecting that version for recovery. Empty files remain valid. Other filesystem errors propagate.

Regression tests verify that recovery returns the exact bytes from v1, the next update writes and reopens v3, and failed reads and updates preserve both directories when neither version is complete. The tests use synthetic slots.

All 13 XGameSave tests passed. The full victory-hle suite passed with 145 library tests and two integration tests, both serially and on a parallel rerun. The first parallel run had one failure in dstorage::tests::a_page_list_filled_after_its_request_starts. Clippy passed for victory-hle with all targets, all features, and warnings treated as errors.

**@⁠WerG0D** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1981) `WerG0D:fix/recover-incomplete-save` → `main` · +58 −4 · 1 files · 1 commits · open On Windows/NTFS, I reproduced a failed read that also deleted the last complete save version. On `940d32f`, I created a complete `v1` and a `v2` whose manifest listed two blobs but whose directory contained only the first. Reading the slot removed `v1` and then returned an error for the missing file. This change checks that each numbered blob named by the manifest exists as a regular file before selecting that version for recovery. Empty files remain valid. Other filesystem errors propagate. Regression tests verify that recovery returns the exact bytes from `v1`, the next update writes and reopens `v3`, and failed reads and updates preserve both directories when neither version is complete. The tests use synthetic slots. All 13 XGameSave tests passed. The full `victory-hle` suite passed with 145 library tests and two integration tests, both serially and on a parallel rerun. The first parallel run had one failure in `dstorage::tests::a_page_list_filled_after_its_request_starts`. Clippy passed for `victory-hle` with all targets, all features, and warnings treated as errors.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:50:39 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-25 02:16 UTC · original

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-25 02:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7150511030) ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-25 02:20 UTC · original

Verified locally on Windows 11 26300 (NTFS), Rust 1.98.1 MSVC. 1d46b2f sits directly on main 940d32f.

  • The bug is real on main, and the tests catch it. With only this PR's test module on main's xgamesave.rs, two tests fail with the data loss described:
    • an_unreadable_newer_version_does_not_cost_the_save: missing second blob: v1 was removed; read returned Err(-2138898430)
    • incomplete_versions_survive_failed_reads_and_updates: read removed v1: Err(-2138898430)
      With the PR, both pass.
  • Stable: cargo test -p victory-hle --lib --locked 10 runs in a row, 145 passed every time (parallel test threads).
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean.

Not tested: the title's own save path (this machine can't get far enough into the game to save).

AI use: Claude Code (Claude Opus 5.5) ran these checks and wrote this; the results are from the runs described.

**@⁠AgneyaK** on GitHub · 2026-11-25 02:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7150608303) Verified locally on Windows 11 26300 (NTFS), Rust 1.98.1 MSVC. `1d46b2f` sits directly on `main` `940d32f`. - **The bug is real on `main`, and the tests catch it.** With only this PR's test module on `main`'s `xgamesave.rs`, two tests fail with the data loss described: - `an_unreadable_newer_version_does_not_cost_the_save`: `missing second blob: v1 was removed; read returned Err(-2138898430)` - `incomplete_versions_survive_failed_reads_and_updates`: `read removed v1: Err(-2138898430)` With the PR, both pass. - **Stable:** `cargo test -p victory-hle --lib --locked` 10 runs in a row, `145 passed` every time (parallel test threads). - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean. Not tested: the title's own save path (this machine can't get far enough into the game to save). AI use: Claude Code (Claude Opus 5.5) ran these checks and wrote this; the results are from the runs described.
Author
Owner

@⁠Yoshi-233 on GitHub · 2026-11-25 03:27 UTC · original

I checked one more recovery case on Linux/ext4 at 1d46b2f: a newer blob can be a regular file whose metadata is readable, even though opening it for reading returns PermissionDenied. On the PR, that can still cost the older readable save.

I ran the PR's load, current, current_named and read functions in a small native Rust harness with temporary synthetic version directories as a non-root user. Both manifests declared one blob. I wrote OLD under v1/0, wrote NEW under v2/0, then set only v2/0 to mode 000. I confirmed metadata still reported a regular file and a read-only open failed. Reading the slot returned an error, but by then v1 had been pruned. I saw the same on the base.

The existing missing-blob fix worked in the same harness: an absent blob or a directory at v2/0 recovered the exact old bytes and kept v1. A readable zero-length blob correctly selected v2.

In a local control, attempting a read-only open of each regular blob in load before selecting the version propagated the permission error and kept the old bytes on disk; the other cases kept their outcomes. This only checks open-time failure. I haven't checked denied reads or sharing violations on Windows/NTFS.

**@⁠Yoshi-233** on GitHub · 2026-11-25 03:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7151931399) I checked one more recovery case on Linux/ext4 at `1d46b2f`: a newer blob can be a regular file whose metadata is readable, even though opening it for reading returns `PermissionDenied`. On the PR, that can still cost the older readable save. I ran the PR's `load`, `current`, `current_named` and `read` functions in a small native Rust harness with temporary synthetic version directories as a non-root user. Both manifests declared one blob. I wrote `OLD` under `v1/0`, wrote `NEW` under `v2/0`, then set only `v2/0` to mode 000. I confirmed metadata still reported a regular file and a read-only open failed. Reading the slot returned an error, but by then `v1` had been pruned. I saw the same on the base. The existing missing-blob fix worked in the same harness: an absent blob or a directory at `v2/0` recovered the exact old bytes and kept `v1`. A readable zero-length blob correctly selected `v2`. In a local control, attempting a read-only open of each regular blob in `load` before selecting the version propagated the permission error **and kept the old bytes on disk**; the other cases kept their outcomes. This only checks open-time failure. I haven't checked denied reads or sharing violations on Windows/NTFS.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:26 UTC · original

Automated triage for the maintainers.

Merge candidate.

This fixes real data loss in crates/victory-hle/src/modules/xgamesave.rs. On main, current takes the newest version whose manifest parses and then prunes every older version. A newer version whose manifest names a blob file that is missing then cost the last complete save, and the read failed anyway. With this change, load treats such a version as unreadable: the blob is absent or not a regular file, while other I/O errors still propagate. current then falls back to the older version without removing it, as it already does for broken manifests.

What I checked:

  • Prune order: the loop in current only prunes after load returns Some, so the fallback keeps older versions until a complete one is found.
  • Empty blobs: empty blobs still count as present.
  • Tests: the new tests cover both the fallback and the case where no version is complete. A contributor reports that both fail on main.

A possible follow-up, not a blocker: a blob that exists but cannot be opened (permission denied, as reported in a comment) still selects that version. main behaves the same way there.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 08:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7157019666) <!-- victory-triage v1 head=1d46b2f87936936e1ffddd5407cf89c19f34e9ac verdict=merge-candidate at=2026-11-25T08:25:53Z --> Automated triage for the maintainers. **Merge candidate.** This fixes real data loss in `crates/victory-hle/src/modules/xgamesave.rs`. On `main`, `current` takes the newest version whose manifest parses and then prunes every older version. A newer version whose manifest names a blob file that is missing then cost the last complete save, and the read failed anyway. With this change, `load` treats such a version as unreadable: the blob is absent or not a regular file, while other I/O errors still propagate. `current` then falls back to the older version without removing it, as it already does for broken manifests. What I checked: - **Prune order:** the loop in `current` only prunes after `load` returns `Some`, so the fallback keeps older versions until a complete one is found. - **Empty blobs:** empty blobs still count as present. - **Tests:** the new tests cover both the fallback and the case where no version is complete. A contributor reports that both fail on `main`. A possible follow-up, not a blocker: a blob that exists but cannot be opened (permission denied, as reported in a comment) still selects that version. `main` behaves the same way there. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:02 UTC · original

Automated triage for the maintainers, second look (a review against main, with the PR built and tested).

Protecting an older complete save behind a newer one that is missing a blob is right, and this can be merged after one change. As it stands, a container whose only version lost a blob refuses every later save (a probe got an access error on each update), where main lets the next update that rewrites every blob commit, so the save heals. In crates/victory-hle/src/modules/xgamesave.rs current, please take the newest complete version, and when no version is complete take the newest whose manifest parses, as main does, instead of returning the "no complete save version" error (for example, load returns the names plus a complete flag and current loops twice; versions are pruned only below the one taken). Then incomplete_versions_survive_failed_reads_and_updates should expect the update to succeed above v2, and a new case should cover "the only version lost a blob; an update that rewrites it returns S_OK".

Push the change and it will be reviewed again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 22:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7175862361) Automated triage for the maintainers, second look (a review against `main`, with the PR built and tested). Protecting an older complete save behind a newer one that is missing a blob is right, and this can be merged after one change. As it stands, a container whose only version lost a blob refuses every later save (a probe got an access error on each update), where `main` lets the next update that rewrites every blob commit, so the save heals. In `crates/victory-hle/src/modules/xgamesave.rs` `current`, please take the newest complete version, and when no version is complete take the newest whose manifest parses, as `main` does, instead of returning the "no complete save version" error (for example, `load` returns the names plus a `complete` flag and `current` loops twice; versions are pruned only below the one taken). Then `incomplete_versions_survive_failed_reads_and_updates` should expect the update to succeed above v2, and a new case should cover "the only version lost a blob; an update that rewrites it returns S_OK". Push the change and it will be reviewed again. Thank you for the contribution.
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/1981/head:github-bot/gh-1981'
git switch 'github-bot/gh-1981'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1981'
git switch 'github-bot/gh-1981'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1981'
git switch 'github-bot/gh-1981'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1981'
git switch 'main'
git merge --squash 'github-bot/gh-1981'
git switch 'main'
git merge --ff-only 'github-bot/gh-1981'
git switch 'main'
git merge 'github-bot/gh-1981'
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/Marvisak--VIctory!1981
No description provided.