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

Open
WerG0D wants to merge 1 commit from upstream-pr/1981 into main
WerG0D commented 2026-11-25 02:15:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by WerG0D on 2026-11-25T02:15:46Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6595611465 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1981). Originally posted by [WerG0D](https://github.com/WerG0D) on 2026-11-25T02:15:46Z. --- 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.
catminou4 commented 2026-11-25 02:48:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:48:47Z.

Review: COMMENTED


Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.

Preserve the last complete save when a newer version misses a blob — save-game corruption hardening; right fallback semantics.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051088377 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1981#pullrequestreview-6051088377). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:48:47Z. **Review:** COMMENTED --- Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff. Preserve the last complete save when a newer version misses a blob — save-game corruption hardening; right fallback semantics.
DesertGamer commented 2026-11-25 03:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-25T02:16:00Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150511030 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7150511030). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-25T02:16:00Z. --- ### 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.*
AgneyaK commented 2026-11-25 03:03:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-25T02:20:57Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150608303 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7150608303). Originally posted by [AgneyaK](https://github.com/AgneyaK) on 2026-11-25T02:20:57Z. --- 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.
Yoshi-233 commented 2026-11-25 04:06:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Yoshi-233 on 2026-11-25T03:27:27Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151931399 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7151931399). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-25T03:27:27Z. --- 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.
Marvisak commented 2026-11-25 09:06:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:26:03Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157019666 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7157019666). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:26:03Z. --- <!-- 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)_
Marvisak commented 2026-11-25 22:04:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:02:36Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175862361 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1981#issuecomment-7175862361). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:02:36Z. --- 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.
fuzeofficlal commented 2026-11-26 18:42:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T18:42:36Z.

Review: CHANGES_REQUESTED


Verified 1d46b2f87936936e1ffddd5407cf89c19f34e9ac merged onto main (63bcca43) on Windows 11 x64 (xtask policy: 191 files ok; cargo clippy --locked -p victory-hle --all-targets -- -D warnings: clean; cargo test --locked -p victory-hle --lib modules::xgamesave::: 13 passed, 0 failed).

Echoing the pending second-look triage note from 2026-11-25:

  • Blocker (crates/victory-hle/src/modules/xgamesave.rs:253-257, 1526-1531): When no complete save version exists on disk (e.g., the container's only version lost a blob), current() returns Err("no complete save version") (NO_ACCESS) even for update(), permanently blocking a subsequent update that writes every blob from healing the container (whereas main allows the new version to commit). Selecting the newest complete version when one exists and falling back to the newest version whose manifest parses when none is complete (pruning only versions older than the chosen one), along with a test asserting an all-blob rewrite recovers with S_OK, will resolve this cleanly.
  • Non-blocking note (xgamesave.rs:202-209): load() checks std::fs::metadata (is_file()) without checking read access, so an unreadable regular blob (e.g., PermissionDenied) can still select that version and prune older ones before read fails.
<!-- greyfinch-sync:Marvisak/VIctory:review:6079109397 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1981#pullrequestreview-6079109397). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T18:42:36Z. **Review:** CHANGES_REQUESTED --- Verified `1d46b2f87936936e1ffddd5407cf89c19f34e9ac` merged onto `main` (`63bcca43`) on Windows 11 x64 (`xtask policy`: `191 files ok`; `cargo clippy --locked -p victory-hle --all-targets -- -D warnings`: clean; `cargo test --locked -p victory-hle --lib modules::xgamesave::`: `13 passed, 0 failed`). Echoing the pending second-look triage note from 2026-11-25: - **Blocker (`crates/victory-hle/src/modules/xgamesave.rs:253-257, 1526-1531`)**: When no complete save version exists on disk (e.g., the container's only version lost a blob), `current()` returns `Err("no complete save version")` (`NO_ACCESS`) even for `update()`, permanently blocking a subsequent update that writes every blob from healing the container (whereas `main` allows the new version to commit). Selecting the newest complete version when one exists and falling back to the newest version whose manifest parses when none is complete (pruning only versions older than the chosen one), along with a test asserting an all-blob rewrite recovers with `S_OK`, will resolve this cleanly. - **Non-blocking note (`xgamesave.rs:202-209`)**: `load()` checks `std::fs::metadata` (`is_file()`) without checking read access, so an unreadable regular blob (e.g., `PermissionDenied`) can still select that version and prune older ones before `read` fails.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1981:upstream-pr/1981'
git switch 'upstream-pr/1981'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1981'
git switch 'upstream-pr/1981'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1981'
git switch 'upstream-pr/1981'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1981'
git switch 'main'
git merge --squash 'upstream-pr/1981'
git switch 'main'
git merge --ff-only 'upstream-pr/1981'
git switch 'main'
git merge 'upstream-pr/1981'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1979
No description provided.