Repository navigation
Loader: stage prepared images in per-writer files - #560
Conversation
2a159ba to
49df7e1
Compare
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 49df7e1 on Windows 11, RTX 5070, MSVC: the workspace passes (197 outside victory-shader), including both publish tests.
- A per-process, per-call staging name (
.<name>.<pid>.<seq>.tmp) removes the shared<hash>.tmpthat two cold launches could truncate under each other. A failed rename now removes its staging file instead of leaving it in the cache. - Remaining Windows race, not introduced here: if both launches pass the "already equal?" read before either publishes, the second
renamereplaces a file the first may already have mapped. Windows refuses to replace a mapped file, so the second launch gets an error. That is the same outcome as before. A follow-up could treat a failed rename as success when the destination now reads equal tobytes.
No issues found.
AI-assisted (Claude Code).
…writer files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
Also, AI-assisted. |
catminou4
left a comment
There was a problem hiding this comment.
Clean portability fix: write_if_changed moves from windows.rs into a shared publish module, and the staging file is now unique per process+call (.{name}.{pid}.{seq}.tmp) instead of a fixed .tmp sibling. Two runner instances preparing the same title can no longer truncate each other's staging bytes or rename over each other's publish; the final rename stays atomic within the directory and failures clean up the staging file.
The read-compare-write fast path and with_context error reporting are preserved. Unit tests cover both the concurrent-publisher case and the failed-publication cleanup.
Verified locally: test-merge with current main (ffe310e) clean; cargo test -p victory-loader --locked publish (macOS arm64, rustc 1.98.1) → 2 passed / 0 failed (the 3 prepare::tests failures in the full suite are the pre-existing Mach-O-vs-PE platform issue on main, unrelated).
write_if_changed used a shared <hash>.tmp file, so two concurrent cold launches of the same image could truncate each other's staging bytes or fail the rename after the other had published. Move publication into a portable module that stages under a unique pid/sequence name and removes it on failure. Two hermetic tests cover concurrent publishers and a failed rename.
49df7e1 to
1aac20a
Compare
Merges Marvisak#188 Marvisak#213 Marvisak#214 Marvisak#219 Marvisak#221 Marvisak#311 Marvisak#324 Marvisak#363 Marvisak#406 Marvisak#454 Marvisak#529 Marvisak#560 Marvisak#708 Marvisak#937 Marvisak#941 Marvisak#963 Marvisak#1111 Marvisak#1159 Marvisak#1304 Marvisak#1306 onto main (ffe310e), each head unchanged, no conflicts. One change of mine: the long-format import descriptor code Marvisak#963 adds nests `if size == 0` in an `if let`, which clippy::collapsible_if rejects under -D warnings; it is now one `if let ... && size == 0` (clippy --fix, no change of behaviour). cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, is clean and cargo test --workspace --locked passes (388 passed, 7 ignored; main has 342 passed, 6 ignored). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
What
write_if_changedstaged every prepared image into the same<hash>.tmpfile. Two cold launches of the same title could truncate eachother's staged bytes, or the second rename could fail after the first had
already published a correct image. Publication now lives in a portable
module that stages under a name unique to the process and call, and removes
the staging file if the rename fails. The Windows loader path delegates to
it; the file content and cache layout are unchanged.
An AI tool wrote part of this change.
Tested
cargo test --workspace: 166 passed, 0 failed, 3 ignored. Two hermetic tests: concurrent publishers of the same destination both succeed with the exact bytes and leave no staging files, and a failed publication leaves none behind.cargo check --target x86_64-pc-windows-gnu --workspace --testspasses. No Windows host here, so the actualLoadLibraryExWstep was not exercised.cargo xtask policypasses (151 files ok). No game files or data from them were added.Checklist
cargo xtask policypasses. No game files or data from them were added.