XGameSave: a stray or unreadable version folder never costs the save (#870) #1728
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1729"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by moe-miau on 2026-11-24T21:27:01Z.
Fixes #870, including the case found in the review of the earlier attempts.
The three PRs for #870 (#1006, #1035, #1102) were closed by their authors, so nothing open fixes it on its own. As measured in the issue, they covered
v01-style names but not a correctly named stray: an emptyv2, a file namedv2, or av2with a broken manifest next to a committedv1still cost the save.v1was pruned as older, the read failed, and the next update returnedS_OKwhile committing a freshv1with only the changed blobs, which the following read pruned again.Change (
crates/victory-hle/src/modules/xgamesave.rsonly)v<N>exactly ascommitwrites it is a version (version_number): no leading zeros, no sign, notv0.v01,v+1,v001are neither read, counted nor removed.currenttakes the newest version whose manifest reads, removes only versions below it, and leaves unreadable newer entries alone. Only directories are versions.Version::highest), so a strayv2neither hides the save nor blocks writes; the next read then treats the stray as older and removes it.NO_ACCESS) and nothing is removed, as before.This follows the "fuller fix" in winne42's comment on #870. A crash between
commit's rename and the removal of the old version still leaves two readable versions, of which the newer one wins, as before.Tests
Three synthetic tests in temporary directories (no game data):
a_noncanonical_folder_does_not_remove_a_committed_save:v01,v001,v+1,v0,v02next tov1.an_unreadable_newer_version_does_not_cost_the_save: an emptyv2folder, a file namedv2, and av2with a broken manifest. Each reads the old save, keepsv1, then updates (lands asv3with the kept blob), and reads again.no_readable_version_is_refused_and_kept: a corrupt only version is refused for read and update and stays on disk.The first two fail on
main(ffe310e) with only the tests applied (the committed save is removed), and pass with the change. The existing crash test (a_kill_at_any_step_leaves_old_or_new) and the other save tests pass unchanged.On Windows 11 x64, Rust 1.98.1 MSVC:
cargo clippy --workspace --all-targets --locked -- -D warnings, and the--all-featuresvariant: cleancargo test --workspace --locked: pass (victory-hle: 97 passed)cargo xtask policy: okAI-assisted (Claude Code); I reviewed the change and ran the checks.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:36:45Z.
Review: COMMENTED
Static review only: this crate is Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff.
XGameSave stray/unreadable version folders: version_number() accepts only canonical 'v' (rejects v01, v+1, v0 via format round-trip), load() treats a missing manifest as Ok(None) and a parse failure as None too, and 'highest' tracks the max version across entries so the next commit goes above it. The canonical-name check is a nice guard against weird folder names. HLE is Windows-only — static review.
Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-24T22:49:46Z.
Reviewed and verified: 10/10 xgamesave tests pass on Windows, including
the three new ones — a stray
v01no longer removes the committedsave, an unreadable newer version neither hides nor prunes it and the
next update goes above it, and with nothing readable nothing is removed
and reads fail. Canonical
v<N>only, directories only,highest + 1to commit: solid.