flush a kept save blob that had to be copied #1666

Merged
imjustprism merged 1 commit from upstream-pr/1667 into main 2026-11-25 00:15:14 +00:00
imjustprism commented 2026-11-24 20:35:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by imjustprism on 2026-11-24T20:35:56Z.


when a save update keeps a blob, commit hard-links it from the previous version, and if the link fails it falls back to std::fs::copy. that copy was never flushed, but the new version is renamed in and the old one deleted right after, so a power cut could leave a committed version with an empty kept blob and no old version to go back to. the fallback now goes through the same write + sync_all as new data.

the fallback only runs where hard links fail: a data folder on a volume without them (fat32/exfat, some shares), or a blob that already has 1024 links. i checked on ntfs that another process holding the old blob open does not make the link fail, so that is not a trigger.

no test can see whether bytes reached the disk, so there is no test that fails without this. the new test forces the fallback through the ntfs link limit and checks the committed version has the kept blob's exact bytes, which nothing covered before. clippy both ways, cargo test --workspace (343 passed) and xtask policy on windows 11.

touches the same two lines as #237.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6590904326 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1667). Originally posted by [imjustprism](https://github.com/imjustprism) on 2026-11-24T20:35:56Z. --- when a save update keeps a blob, commit hard-links it from the previous version, and if the link fails it falls back to std::fs::copy. that copy was never flushed, but the new version is renamed in and the old one deleted right after, so a power cut could leave a committed version with an empty kept blob and no old version to go back to. the fallback now goes through the same write + sync_all as new data. the fallback only runs where hard links fail: a data folder on a volume without them (fat32/exfat, some shares), or a blob that already has 1024 links. i checked on ntfs that another process holding the old blob open does not make the link fail, so that is not a trigger. no test can see whether bytes reached the disk, so there is no test that fails without this. the new test forces the fallback through the ntfs link limit and checks the committed version has the kept blob's exact bytes, which nothing covered before. clippy both ways, cargo test --workspace (343 passed) and xtask policy on windows 11. touches the same two lines as #237.
catminou4 commented 2026-11-24 22:01:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:41:50Z.

Review: COMMENTED


Static review only: Windows-only code (D3D12/windows_sys/Win32/HLE) — nothing compiles or runs on macOS; source review of the diff.

Kept save blobs that hit the NTFS 1024-hard-link limit are now copied with exact bytes instead of failing the commit: Source::Kept tries hard_link then falls back to read+write. The test is excellent — it creates 1023 links to fill the limit, asserts TooManyLinks on the 1025th, commits a new version keeping blob 'b', and verifies state. Windows-only (cfg(windows) test).

<!-- greyfinch-sync:Marvisak/VIctory:review:6047870573 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1667#pullrequestreview-6047870573). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:41:50Z. **Review:** COMMENTED --- Static review only: Windows-only code (D3D12/windows_sys/Win32/HLE) — nothing compiles or runs on macOS; source review of the diff. Kept save blobs that hit the NTFS 1024-hard-link limit are now copied with exact bytes instead of failing the commit: Source::Kept tries hard_link then falls back to read+write. The test is excellent — it creates 1023 links to fill the limit, asserts TooManyLinks on the 1025th, commits a new version keeping blob 'b', and verifies state. Windows-only (cfg(windows) test).
acetonahard-code commented 2026-11-24 23:05:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T22:09:37Z.


Tested on Windows 11 with the repo toolchain, merged into current main (70564ae):

cargo test -p victory-hle passed failed ignored
main 99 0 0
main + this PR 100 0 0
  • The new test passes.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145880609 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1667#issuecomment-7145880609). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T22:09:37Z. --- Tested on Windows 11 with the repo toolchain, merged into current `main` (70564ae): | `cargo test -p victory-hle` | passed | failed | ignored | |---|---|---|---| | `main` | 99 | 0 | 0 | | `main` + this PR | 100 | 0 | 0 | - The new test passes. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
upstream-sync closed this pull request 2026-11-25 01:06:59 +00:00
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!1666
No description provided.