pipeline: remove staging files when cache publication fails #161

Manually merged
github merged 1 commit from gh-pr/161/head into gh-pr/161/base 2026-11-26 03:52:45 +00:00
Owner

@⁠lordon1a on GitHub · 2026-11-24 01:01 UTC · original
fix/pipeline-staging-cleanup → main · +31 −2 · 1 files · 1 commits · merged 2026-11-24 07:52 UTC

Summary

When Cache::get_or_convert() (crates/victory-pipeline/src/cache.rs) fails to write or rename its staging file into the final cache path, the orphaned temporary file was left behind in the cache directory.

This change:

  1. Opens the staging path with OpenOptions::new().write(true).create_new(true) instead of std::fs::write, drops the file handle before rename (required on Windows), and removes the staging file if writing or publishing fails.
  2. Adds a synthetic unit test (failed_publication_removes_the_staging_file) that creates a directory at the target cache path to force rename failure and verifies no staging file remains.

Verification

Tested on Windows 11 (rustc 1.100.0, x86_64-pc-windows-gnullvm):

  • cargo test -p victory-pipeline: 4 passed, 0 failed (the new test fails on main@9aef3d9 where the staging file is left behind).
  • cargo clippy -p victory-pipeline --all-targets: 0 warnings.
  • cargo xtask policy: 151 files ok (zero game data).

AI-assisted.

**@⁠lordon1a** on GitHub · 2026-11-24 01:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/161) `fix/pipeline-staging-cleanup` → `main` · +31 −2 · 1 files · 1 commits · merged 2026-11-24 07:52 UTC ## Summary When `Cache::get_or_convert()` (`crates/victory-pipeline/src/cache.rs`) fails to write or rename its staging file into the final cache path, the orphaned temporary file was left behind in the cache directory. This change: 1. Opens the staging path with `OpenOptions::new().write(true).create_new(true)` instead of `std::fs::write`, drops the file handle before `rename` (required on Windows), and removes the staging file if writing or publishing fails. 2. Adds a synthetic unit test (`failed_publication_removes_the_staging_file`) that creates a directory at the target cache path to force `rename` failure and verifies no staging file remains. ## Verification Tested on Windows 11 (`rustc 1.100.0`, `x86_64-pc-windows-gnullvm`): - `cargo test -p victory-pipeline`: **4 passed, 0 failed** (the new test fails on `main@9aef3d9` where the staging file is left behind). - `cargo clippy -p victory-pipeline --all-targets`: **0 warnings**. - `cargo xtask policy`: **151 files ok** (zero game data). AI-assisted.
Reserve a new staging path and clean it up if writing or publishing fails. Cover a failed publication with a synthetic destination directory.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:44 +00:00
github manually merged commit 7d73e2b249 into gh-pr/161/base 2026-11-26 03:52:45 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:21 UTC · original

The test target does not compile, so the GPU suite cannot run:

error[E0428]: the name `tests` is defined multiple times
    --> crates/victory-gpu/src/host.rs:1974:1
 252 | mod tests { ... }
1974 | mod tests { ... }

The library builds; only cargo test fails, on every platform. The new test module needs to go into the existing mod tests in host.rs after a rebase (the same failure as #134/#135/#175).

No game data used.

**@⁠DaviTostes** on GitHub · 2026-11-24 01:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/161#issuecomment-7119022562) The **test target does not compile**, so the GPU suite cannot run: ``` error[E0428]: the name `tests` is defined multiple times --> crates/victory-gpu/src/host.rs:1974:1 252 | mod tests { ... } 1974 | mod tests { ... } ``` The library builds; only `cargo test` fails, on every platform. The new test module needs to go into the existing `mod tests` in `host.rs` after a rebase (the same failure as #134/#135/#175). No game data used.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!161
No description provided.