pipeline: remove staging files when cache publication fails #161

Merged
lordon1a merged 1 commit from upstream-pr/161 into main 2026-11-24 07:52:35 +00:00
lordon1a commented 2026-11-24 01:01:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by lordon1a on 2026-11-24T01:01:53Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572189250 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/161). Originally posted by [lordon1a](https://github.com/lordon1a) on 2026-11-24T01:01:53Z. --- ## 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.
copilot-pull-request-reviewer[bot] commented 2026-11-24 01:02:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T01:02:01Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Marvisak/VIctory:review:6032025476 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/161#pullrequestreview-6032025476). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-24T01:02:01Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
DaviTostes commented 2026-11-24 06:54:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:21:39Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7119022562 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/161#issuecomment-7119022562). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T01:21:39Z. --- 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.
upstream-sync closed this pull request 2026-11-24 08:01:53 +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!161
No description provided.