XGameSave: clear stray files at staged version paths #2714
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2716"
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 TaynanGT on 2026-11-25T18:42:00Z.
Problem
XGameSave stages a save version in
v<N>.newbefore renaming it tov<N>. If a regular file occupies that staging path,remove_dir_allreturnsNotADirectory(Windows error 267). This can hide the last committed save during recovery and block a new commit.Change
Use the same cleanup for recovery and commit. It removes a staging entry according to its type. Recovery uses the existing canonical version-name parser to clean up
v<N>.newentries and preserve unrelated names such asnotes.new.Verification
mainat13f91cawith the two regression tests applied by themselves, both tests fail withNotADirectory.cargo test -p victory-hle --lib --locked staged_version_filepasses both tests. They cover reading the committed save, preserving an unrelated file, and replacing the stale staging file on commit.cargo test -p victory-hle --lib --lockedpasses all 148 tests.cargo xtask policy --stagedpassed before commit. The tests use temporary files and synthetic data.Follow-up from review
On Windows, a file opened without delete sharing cannot be removed. Recovery now tries to clear an unfinished version without requiring deletion to succeed before reading the committed save. Writing a new version still requires the staging path it will reuse to be clear.
The new test,
a_locked_staged_version_file_only_blocks_commit, failed on the previous PR head with Windows error 32. It now verifies that the old save stays readable whilev2.newis locked, the write fails while the lock is held, and a retry commits the new version after the lock is released. All 149victory-hleunit tests andcargo clippy -p victory-hle --all-targets --all-features --locked -- -D warningspassed.The Windows CI run for
3e5cdb8passed both Clippy checks and the full workspace test suite.Adapted from TaynanGT/VIctory@8ffb049 in #2257. Related #1981 covers recovery when a committed version is missing a blob. Prepared with Codex assistance.
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:45:18Z.
current()still returns an error before reading a valid committed save if it can’t delete an unpublishedv<N>.newentry. I confirmed on Windows that deleting a temporary file fails while it’s held open without delete sharing. In this path,remove_staged_version(...)?propagates that error beforecurrent()checks the committed manifest.Could cleanup be best-effort in
current(), whilecommit()still requires cleanup of the staging path it will reuse? A Windows regression could holdv2.newopen without delete sharing and verify thatv1remains readable.AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:51:41Z.
Correct on both halves: remove_staged_version dispatches on symlink_metadata (dir / dir-symlink / other), and the recovery sweep now only touches names that parse as v.new so unrelated *.new files survive. Sharing the helper between recovery and commit is the right consolidation.
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T19:53:24Z.
Review: APPROVED
No description provided.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T19:31:06Z.
Independent local verification of PR #2716 (claim
VERIFY-2716-XGAMESAVE-STAGINGon #1633).Environment: Windows, rustc/cargo 1.100.0, MSVC,
CARGO_BUILD_JOBS=2,--locked. No game data, no GPU, no clippy/rustup.cargo test --locked -p victory-hle --lib staged_version_file --quiet→ 3 passed, 0 failed (146 filtered).cargo test --locked -p victory-hle --lib --quiet→ 149 passed, 0 failed, 0 ignored.git diff --check origin/main..HEAD→ clean.remove_staged_versionand the three new test names are absent fromorigin/mainincrates/victory-hle/src/modules/xgamesave.rs(git grepno matches), so the added tests are genuinely new.Only pre-existing
#[warn(deprecated)]notes in the crate (fetch_update) appeared; non-blocking. No functional issues found. AI-assisted (Hy4 flash).Imported from Marvisak/VIctory. Originally posted by TaynanGT on 2026-11-25T19:41:29Z.
@DrDarkDK Done in
520268f:current()now ignores a failed cleanup of av<N>.newentry, so a locked staging file no longer hides the committed save, whilecommit()still has to clear the staging path it reuses. The Windows testa_locked_staged_version_file_only_blocks_commitholdsv2.newopen without sharing, checks thatv1stays readable and that the update returnsNO_ACCESS, then releases the file and checks that the update succeeds.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:42:39Z.
Independent Windows 11 verification and review of
3e5cdb8(on13f91ca):Verification (
rustc 1.98.1MSVC)cargo xtask policy: 184 files ok.cargo clippy --locked -p victory-hle --all-targets -- -D warnings: 0 warnings.cargo test --locked -p victory-hle: 149 passed, 0 failed (lib, including all 3 new staged-file tests and the Windows file-lock test), plusfidelityfx(1) andno_dll_planting(1) clean.xgamesave.rs: clean zero-conflict 3-waygit merge-treewith #2674, #2675, and #2720 (and clean 3-way sequential merge of#2716 + #2720 + #2674).Review Notes
remove_staged_versionusessymlink_metadataand checksis_symlink_diron Windows (callingremove_dirrather than recursing through reparse points),current()restricts best-effort cleanup strictly tov<n>.newnames without blocking reads on locked strays, andcommit()strictly propagates removal errors before staging. Clean and ready to merge.Imported from Marvisak/VIctory. Originally posted by TaynanGT on 2026-11-25T21:17:00Z.
Thanks, @kotekompotek, for reviewing the staging cleanup, and @cloph-dsp and @fuzeofficlal for testing it on Windows. The lock test confirms that the previous save stays readable, the write fails while the staging file is locked, and the retry succeeds after the file is released. I appreciate you checking the base branch and the related PRs as well.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:18:35Z.
Automated triage for the maintainers.
In
crates/victory-hle/src/modules/xgamesave.rs, the newremove_staged_versionclears av<N>.newstaging path whether it holds a directory, a directory symlink or a file.currentnow removes unfinished versions on a best-effort basis and only for names that parse asv<N>.new, so a staging entry it cannot delete no longer hides the last committed save.commitstill fails if it cannot clear the path it reuses. Onmain,currentcallsremove_dir_all(...)?on every*.newentry, so a locked or non-directory entry fails the whole read. VIctory itself never leaves a stray file there, so most of the value is in the best-effort recovery. The three tests (one Windows-only lock test) cover the read, the commit and the retry. CI (check) passes.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
Pull request closed