Repository navigation
Port upstream #560: stage prepared images in per-writer files - #47
Merged
DesertGamer merged 1 commit intoNov 26, 2026
Merged
Conversation
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. (cherry picked from commit 1aac20a)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
This ports Marvisak/VIctory#560 by quaternion. It is cherry-picked with
-x, so the commit keeps their authorship. It applied cleanly.write_if_changedincrates/viport-loader/src/windows.rspublishes a prepared image by writing<hash>.tmpand renaming it over<hash>.dll. Every writer uses the same staging name. So two cold launches of the same image at once can truncate each other's staging bytes, or one rename can fail after the other has already published. A failed rename also leaves the.tmpbehind.The fix moves publication into a portable module,
publish.rs. It stages under a uniquepid/sequence name and removes the staging file when publishing fails. Two tests come with it: concurrent publishers never share a staging file, and a failed rename leaves no staging file behind.Checked
docs/asset-policy.mdbuild.rs, git hook,.cargoconfig, CI change or script (or an issue explains why)cargo test --workspacepasses (onlyviport-loader --libon Linux, see below)cargo clippy --workspace --all-targets --locked -- -D warningspasses (Windows target, run on Linux)rustfmt; I did not reformat lines I did not changeWhat I ran
On Linux, Rust 1.98.1:
cargo test -p viport-loader --lib --locked publish: both new tests pass.publish.rsis portable.write_if_changedas onmain, compiled standalone, with the target path made a non-empty directory so the rename fails:result=Err(IsADirectory), leftover image.tmp exists=true. Every writer stages to the sameimage.tmp.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, cross-checked from Linux on this branch (rebased on the currentmain): clean.cargo test -p viport-loader --lib --lockedon Linux also shows 4 failures inprepare::tests. They read the test binary as a PE, which it is only on Windows, and they fail the same way onmain.Not run: two real launches at once on Windows.
Overlaps
None. No open PR touches
viport-loader.🤖 Generated with Claude Code