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

Open
Caasares wants to merge 1 commit from upstream-pr/338 into main
Caasares commented 2026-11-24 23:36:24 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Caasares on 2026-11-24T23:36:24Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593620807 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/338). Originally posted by [Caasares](https://github.com/Caasares) on 2026-11-24T23:36:24Z. --- 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.*
kaayzouee commented 2026-11-25 01:11:58 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T00:23:19Z.


Duplicate of #322?

<!-- greyfinch-sync:fxceless/victory-fork:comment:7148457353 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/338#issuecomment-7148457353). Originally posted by [kaayzouee](https://github.com/kaayzouee) on 2026-11-25T00:23:19Z. --- Duplicate of #322?
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/338:upstream-pr/338'
git switch 'upstream-pr/338'

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/338'
git switch 'upstream-pr/338'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/338'
git switch 'upstream-pr/338'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/338'
git switch 'main'
git merge --squash 'upstream-pr/338'
git switch 'main'
git merge --ff-only 'upstream-pr/338'
git switch 'main'
git merge 'upstream-pr/338'
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
fxceless/victory-fork!338
No description provided.