Loader: stage prepared images in per-writer files #560
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/560"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T04:56:11Z.
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.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T10:00:37Z.
Review: APPROVED
Tested
49df7e1on Windows 11, RTX 5070, MSVC: the workspace passes (197 outsidevictory-shader), including bothpublishtests..<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.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).
Imported from Marvisak/VIctory. Originally posted by sebastianspicker on 2026-11-24T11:02:10Z.
Tested
49df7e1applied ontomainffe310e(macOS, Rust 1.98.1). Both new tests pass, 5 out of 5 runs, and Windows-target clippy (x86_64-pc-windows-msvc, plain and--all-features) is clean. Three things:publishis only used by tests, socargo clippy -p victory-loader --all-targets -- -D warningsfails on Linux and macOS:static NEXT_STAGING is never usedandfunction write_if_changed is never used.cargo testpasses because it doesn't deny warnings, but a Linux lint job (like the one in #112) would go red.#[cfg(any(windows, test))]onmod publish;would fix it.LoadLibraryExW. Replacing a file that's mapped as a loaded DLL is refused, even though its bytes are already correct. I can't run that here. A cheap fallback would be: if the rename fails andpathnow reads back equal tobytes, remove the staging file and returnOk.std::fs::write(&staging, bytes)fails partway (a full disk), the staging file stays behind. The rename branch already removes it, so the write could do the same.Also,
publish.rsisn't rustfmt-clean (two hunks with rustfmt 1.98.1), thoughmainisn't either yet.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T12:44:20Z.
Review: APPROVED
Clean portability fix:
write_if_changedmoves fromwindows.rsinto a sharedpublishmodule, and the staging file is now unique per process+call (.{name}.{pid}.{seq}.tmp) instead of a fixed.tmpsibling. 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_contexterror 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 3prepare::testsfailures in the full suite are the pre-existing Mach-O-vs-PE platform issue on main, unrelated).