hle(xgamesave): propagate legacy blob read errors instead of dropping blobs during migration #338

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

@⁠Caasares on GitHub · 2026-11-24 23:36 UTC · original
Caasares:fix/xgamesave-migration-read-errors → main · +96 −8 · 1 files · 1 commits · open

Fixes #242

Root cause

migrate in crates/victory-hle/src/modules/xgamesave.rs iterated over the legacy save folder using .read_dir(old).ok()?.flatten().filter_map(...), converting std::fs::read(e.path()).ok()? into None inside the filter_map closure. Any read_dir entry error or fs::read failure on a recognized blob name was silently dropped instead of aborting migration, causing commit to write v1 without the unreadable blob and remove_dir_all(old) to delete the rest of the legacy directory.

Fix

  • Replaced the lossy iterator chain in migrate with an explicit for entry in std::fs::read_dir(old).ok()? loop that propagates directory-entry errors and std::fs::read(entry.path()) errors for recognized blob names via .ok()? before commit, leaving the legacy directory intact so a subsequent call can retry.
  • Preserved skipping unrelated filenames (continue when file.to_str().and_then(decode) is None) and optional .display metadata handling (unwrap_or_default()).
  • Added regression tests in crates/victory-hle/src/modules/xgamesave.rs:
    • unreadable_legacy_blob_leaves_old_layout_for_retry (#[cfg(windows)], locking Header via OpenOptionsExt::share_mode(0))
    • unreadable_legacy_blob_entry_blocks_migration_without_display (unreadable Header directory entry without .display)

Verification

Ran inside wt-vf-242 on Windows:

  • cargo clippy --workspace --all-targets --locked -- -D warnings — passed
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings — passed
  • cargo test --workspace --locked — passed (498 passed, 0 failed, 7 ignored across all workspace crates, including victory-hle 97 unit tests + 1 integration test and xtask policy checks)
  • Verified both new regression tests fail against 2119b0e before the fix and pass after the fix.
  • Checked modified/added lines against rustfmt --edition 2024 --check (rustfmt.toml).

AI-assisted change; contains no game files, keys, or assets.

**@⁠Caasares** on GitHub · 2026-11-24 23:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/338) `Caasares:fix/xgamesave-migration-read-errors` → `main` · +96 −8 · 1 files · 1 commits · open Fixes #242 ### Root cause `migrate` in `crates/victory-hle/src/modules/xgamesave.rs` iterated over the legacy save folder using `.read_dir(old).ok()?.flatten().filter_map(...)`, converting `std::fs::read(e.path()).ok()?` into `None` inside the `filter_map` closure. Any `read_dir` entry error or `fs::read` failure on a recognized blob name was silently dropped instead of aborting migration, causing `commit` to write `v1` without the unreadable blob and `remove_dir_all(old)` to delete the rest of the legacy directory. ### Fix - Replaced the lossy iterator chain in `migrate` with an explicit `for entry in std::fs::read_dir(old).ok()?` loop that propagates directory-entry errors and `std::fs::read(entry.path())` errors for recognized blob names via `.ok()?` before `commit`, leaving the legacy directory intact so a subsequent call can retry. - Preserved skipping unrelated filenames (`continue` when `file.to_str().and_then(decode)` is `None`) and optional `.display` metadata handling (`unwrap_or_default()`). - Added regression tests in `crates/victory-hle/src/modules/xgamesave.rs`: - `unreadable_legacy_blob_leaves_old_layout_for_retry` (`#[cfg(windows)]`, locking `Header` via `OpenOptionsExt::share_mode(0)`) - `unreadable_legacy_blob_entry_blocks_migration_without_display` (unreadable `Header` directory entry without `.display`) ### Verification Ran inside `wt-vf-242` on Windows: - `cargo clippy --workspace --all-targets --locked -- -D warnings` — passed - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` — passed - `cargo test --workspace --locked` — passed (`498` passed, `0` failed, `7` ignored across all workspace crates, including `victory-hle` `97` unit tests + `1` integration test and `xtask` policy checks) - Verified both new regression tests fail against `2119b0e` before the fix and pass after the fix. - Checked modified/added lines against `rustfmt --edition 2024 --check` (`rustfmt.toml`). *AI-assisted change; contains no game files, keys, or assets.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:41:07 +00:00
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 00:23 UTC · original

Duplicate of #322?

**@⁠kaayzouee** on GitHub · 2026-11-25 00:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/338#issuecomment-7148457353) Duplicate of #322?
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/338/head:github-bot/gh-338'
git switch 'github-bot/gh-338'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-338'
git switch 'github-bot/gh-338'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-338'
git switch 'github-bot/gh-338'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-338'
git switch 'main'
git merge --squash 'github-bot/gh-338'
git switch 'main'
git merge --ff-only 'github-bot/gh-338'
git switch 'main'
git merge 'github-bot/gh-338'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.