shader_link_check: restore write mode before unlink on replace failure (SHADER-LINK-CHECK-STAGE-CLEANUP) #807

Open
github-bot wants to merge 1 commit from github-bot/gh-807 into main AGit
Owner

@⁠trigger337 on GitHub · 2026-11-24 14:02 UTC · original
trigger337:fix/shader-link-check-stage-cleanup → main · +25 −0 · 2 files · 1 commits · open

In tools/shader_link_check.py, write_report creates a temporary file and applies published_mode(path) before os.replace. If the target is read-only (e.g. 0o444), temporary.unlink in the finally block fails on Windows with PermissionError (WinError 5) if os.replace fails, leaving the temporary file behind.

Align with the repository standard:

  1. In finally, restore write permissions (try: os.chmod(temporary, 0o600); except OSError: pass) before calling unlink.
  2. Add synthetic regression test verifying PermissionError handling and cleanup on replace failure.

Tests pass (51/51 in test_shader_link_check.py), scripts/check_no_game_data.py passes cleanly.

agent: yes
AI-assisted: yes

**@⁠trigger337** on GitHub · 2026-11-24 14:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/807) `trigger337:fix/shader-link-check-stage-cleanup` → `main` · +25 −0 · 2 files · 1 commits · open In `tools/shader_link_check.py`, `write_report` creates a temporary file and applies `published_mode(path)` before `os.replace`. If the target is read-only (e.g. 0o444), `temporary.unlink` in the `finally` block fails on Windows with `PermissionError` (WinError 5) if `os.replace` fails, leaving the temporary file behind. Align with the repository standard: 1. In `finally`, restore write permissions (`try: os.chmod(temporary, 0o600); except OSError: pass`) before calling `unlink`. 2. Add synthetic regression test verifying `PermissionError` handling and cleanup on replace failure. Tests pass (51/51 in `test_shader_link_check.py`), `scripts/check_no_game_data.py` passes cleanly. agent: yes AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:22:15 +00:00
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 03:59 UTC · original · approved these changes

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed. Only the staging/permission lines change.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 03:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/807#pullrequestreview-6051661929) · **approved these changes** Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed. Only the staging/permission lines change. AI-assisted (Claude).
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 20:57 UTC · original

Reviewed 0f53b3e: write_report restores 0o600 on the staging file before unlink, so a failed replace cannot strand a read-only .shader-link-*.tmp on Windows; same _publish idiom as bvh_index/navmesh_index. Runs on Linux: 51 tests pass on the PR tree; on main with this test file only the new test fails (leftover staging file). Probes: success paths identical on both trees (published 0o444 mode preserved, no leftovers); under simulated Windows unlink denial main leaks the staging file and masks the replace error while the PR cleans up and surfaces the original error - the trigger is Windows-only and was verified on Linux via simulation. No findings. AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 20:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/807#issuecomment-7174421547) Reviewed 0f53b3e: `write_report` restores 0o600 on the staging file before unlink, so a failed replace cannot strand a read-only `.shader-link-*.tmp` on Windows; same `_publish` idiom as bvh_index/navmesh_index. Runs on Linux: 51 tests pass on the PR tree; on main with this test file only the new test fails (leftover staging file). Probes: success paths identical on both trees (published 0o444 mode preserved, no leftovers); under simulated Windows unlink denial main leaks the staging file and masks the replace error while the PR cleans up and surfaces the original error - the trigger is Windows-only and was verified on Linux via simulation. No findings. AI-assisted review. **Recommendation:** Merge
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/807/head:github-bot/gh-807'
git switch 'github-bot/gh-807'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-807'
git switch 'github-bot/gh-807'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-807'
git switch 'github-bot/gh-807'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-807'
git switch 'main'
git merge --squash 'github-bot/gh-807'
git switch 'main'
git merge --ff-only 'github-bot/gh-807'
git switch 'main'
git merge 'github-bot/gh-807'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.