bvh_match: restore write mode before unlink on replace failure and publish mode on Windows (BVH-MATCH-STAGE-CLEANUP) #759

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

@⁠trigger337 on GitHub · 2026-11-24 13:32 UTC · original
trigger337:fix/bvh-match-stage-cleanup → main · +43 −3 · 2 files · 1 commits · open

In tools/bvh_match.py write_json_report:

  1. os.chmod(staged.name, published_mode(destination)) was skipped on Windows (if os.name != "nt":) because unlinking a temporary file chmod'd to read-only mode in finally: failed with PermissionError on Windows. As a result, Windows output files retained NamedTemporaryFile's private 0600 permissions.
  2. Ensure os.chmod(staged.name, 0o600) before os.unlink in finally:, enabling published_mode(destination) on all platforms and ensuring that temporary staging files are never leaked on failed replacements.
  3. Added regression tests in tests/test_bvh_match.py verifying read-only replacement failure staging cleanup with strict Windows unlink emulation, and Windows published mode application.

agent: yes
AI-assisted: yes

**@⁠trigger337** on GitHub · 2026-11-24 13:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/759) `trigger337:fix/bvh-match-stage-cleanup` → `main` · +43 −3 · 2 files · 1 commits · open In `tools/bvh_match.py` `write_json_report`: 1. `os.chmod(staged.name, published_mode(destination))` was skipped on Windows (`if os.name != "nt":`) because unlinking a temporary file chmod'd to read-only mode in `finally:` failed with `PermissionError` on Windows. As a result, Windows output files retained `NamedTemporaryFile`'s private `0600` permissions. 2. Ensure `os.chmod(staged.name, 0o600)` before `os.unlink` in `finally:`, enabling `published_mode(destination)` on all platforms and ensuring that temporary staging files are never leaked on failed replacements. 3. Added regression tests in `tests/test_bvh_match.py` verifying read-only replacement failure staging cleanup with strict Windows unlink emulation, and Windows published mode application. agent: yes AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:19:55 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:33 UTC · original · approved these changes

Audited and verified. Clean-room compliant.

  • Restores 0o600 file mode before unlinking staging file on replace failure in tools/bvh_match.py.
  • Applies published_mode across all platforms.
  • Regression tests in tests/test_bvh_match.py PASS.
**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/759#pullrequestreview-6040113691) · **approved these changes** Audited and verified. Clean-room compliant. - Restores 0o600 file mode before unlinking staging file on replace failure in tools/bvh_match.py. - Applies published_mode across all platforms. - Regression tests in tests/test_bvh_match.py PASS.
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 04:01 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; and the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 04:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/759#pullrequestreview-6051679949) · **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; and the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change. AI-assisted (Claude).
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/759/head:github-bot/gh-759'
git switch 'github-bot/gh-759'

Merge

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