xgamesave: preserve older versions on manifest error #399

Closed
lordon1a wants to merge 1 commit from upstream-pr/399 into main
lordon1a commented 2026-11-24 02:56:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by lordon1a on 2026-11-24T02:56:11Z.


AI-assisted.

Problem

In victory_hle::modules::xgamesave::current, older committed save directories (v1, etc.) were deleted with remove_dir_all before reading and validating the newest version's manifest. If the latest version's manifest was missing, unreadable, or corrupt, the previous good save version had already been destroyed.

Fix

  • Read and validate the latest version's manifest before pruning older committed version directories.
  • Add unit test modules::xgamesave::tests::unreadable_latest_manifest_preserves_previous_version verifying that both a missing manifest and an empty/corrupt manifest preserve v1, and that v1 is pruned once v2's manifest is valid.

Verification

  • cargo xtask policy: 151 files ok
  • cargo test -p victory-hle xgamesave: 6 passed; 0 failed
  • cargo clippy -p victory-hle --all-targets: 0 warnings in xgamesave.rs
<!-- greyfinch-sync:Marvisak/VIctory:issue:6573574328 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/399). Originally posted by [lordon1a](https://github.com/lordon1a) on 2026-11-24T02:56:11Z. --- AI-assisted. ### Problem In `victory_hle::modules::xgamesave::current`, older committed save directories (`v1`, etc.) were deleted with `remove_dir_all` **before** reading and validating the newest version's manifest. If the latest version's manifest was missing, unreadable, or corrupt, the previous good save version had already been destroyed. ### Fix - Read and validate the latest version's manifest before pruning older committed version directories. - Add unit test `modules::xgamesave::tests::unreadable_latest_manifest_preserves_previous_version` verifying that both a missing manifest and an empty/corrupt manifest preserve `v1`, and that `v1` is pruned once `v2`'s manifest is valid. ### Verification - `cargo xtask policy`: `151 files ok` - `cargo test -p victory-hle xgamesave`: `6 passed; 0 failed` - `cargo clippy -p victory-hle --all-targets`: 0 warnings in `xgamesave.rs`
copilot-pull-request-reviewer[bot commented 2026-11-24 06:52:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T02:56:24Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Marvisak/VIctory:review:6032991273 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/399#pullrequestreview-6032991273). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-24T02:56:24Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
jeremygold02 commented 2026-11-24 06:55:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:29:54Z.


Thanks @lordon1a for preserving the previous save version when the latest manifest cannot be read. I tested head 54f8cee58682bcdac13067542b07d1116fb8b66e with:

cargo test --locked -p victory-hle --lib unreadable_latest_manifest_preserves_previous_version -- --test-threads=1

Result: 1 passed, 0 failed (86 filtered out). The test uses a synthetic save layout with an unreadable latest manifest and verifies the older version remains available. It does not exercise a title’s save workflow.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7122073624 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/399#issuecomment-7122073624). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:29:54Z. --- Thanks @lordon1a for preserving the previous save version when the latest manifest cannot be read. I tested head `54f8cee58682bcdac13067542b07d1116fb8b66e` with: ``` cargo test --locked -p victory-hle --lib unreadable_latest_manifest_preserves_previous_version -- --test-threads=1 ``` Result: 1 passed, 0 failed (86 filtered out). The test uses a synthetic save layout with an unreadable latest manifest and verifies the older version remains available. It does not exercise a title’s save workflow.
mercuryVM commented 2026-11-24 13:01:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T12:40:20Z.

Review: APPROVED


Tested 54f8cee on Windows 11, RTX 5070, MSVC: cargo test -p victory-hle 88 passed, including unreadable_latest_manifest_preserves_previous_version.

  • Moving the remove_dir_all of older versions after the newest manifest has been read and parsed means a missing, empty or corrupt latest manifest leaves v1 in place. Before, the last good save was deleted before the new one was known to load.
  • The test covers all three cases: missing, empty, and valid, where pruning happens only once the latest loads.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6039347404 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/399#pullrequestreview-6039347404). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T12:40:20Z. **Review:** APPROVED --- Tested 54f8cee on Windows 11, RTX 5070, MSVC: `cargo test -p victory-hle` 88 passed, including `unreadable_latest_manifest_preserves_previous_version`. - Moving the `remove_dir_all` of older versions after the newest manifest has been read and parsed means a missing, empty or corrupt latest manifest leaves `v1` in place. Before, the last good save was deleted before the new one was known to load. - The test covers all three cases: missing, empty, and valid, where pruning happens only once the latest loads. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 19:02:04 +00:00

Pull request closed

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!399
No description provided.