world_names: restore write mode before unlink on replace failure and publish mode (WORLD-NAMES-STAGE-CLEANUP) #834

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

@⁠trigger337 on GitHub · 2026-11-24 14:22 UTC · original
trigger337:fix/world-names-stage-cleanup → main · +23 −1 · 2 files · 1 commits · open

When writing dictionary JSON atomically in _write_json, apply published_mode to the staged file and reset os.chmod to 0o600 before exiting TemporaryDirectory if os.replace fails, ensuring cleanup does not fail with PermissionError on Windows when replacing a read-only file.

agent: yes
AI-assisted: yes

**@⁠trigger337** on GitHub · 2026-11-24 14:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/834) `trigger337:fix/world-names-stage-cleanup` → `main` · +23 −1 · 2 files · 1 commits · open When writing dictionary JSON atomically in _write_json, apply published_mode to the staged file and reset os.chmod to 0o600 before exiting TemporaryDirectory if os.replace fails, ensuring cleanup does not fail with PermissionError on Windows when replacing a read-only file. agent: yes AI-assisted: yes
When writing dictionary JSON atomically in _write_json, apply published_mode
to the staged file and reset os.chmod to 0o600 before exiting TemporaryDirectory
if os.replace fails, ensuring cleanup does not fail with PermissionError on
Windows when replacing a read-only file.

agent: yes
AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:23:43 +00:00
Author
Owner

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

Consistent atomic file staging hygiene across Windows and POSIX:

  • Permission Retention on Atomic Replace Failure:
    • ools/world_names.py::_write_json applies published_mode(path) to the staging file. On Windows, if os.replace fails (e.g., target file locked by anti-malware or indexing service), having read-only permissions on mp blocks subsequent cleanup.
    • Adding except BaseException: os.chmod(tmp, 0o600); raise guarantees mp is restored to write mode so the enclosing context can cleanly unlink it.
  • Unit Test Coverage:
    • ests/test_world_names.py tests simulated os.replace failure and validates that os.chmod with
**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/834#pullrequestreview-6041007957) · **approved these changes** ### Clean-Room Peer Review for PR #834 (world_names: restore write mode before unlink on replace failure and publish mode) Consistent atomic file staging hygiene across Windows and POSIX: - **Permission Retention on Atomic Replace Failure**: - ools/world_names.py::_write_json applies published_mode(path) to the staging file. On Windows, if os.replace fails (e.g., target file locked by anti-malware or indexing service), having read-only permissions on mp blocks subsequent cleanup. - Adding except BaseException: os.chmod(tmp, 0o600); raise guarantees mp is restored to write mode so the enclosing context can cleanly unlink it. - **Unit Test Coverage**: - ests/test_world_names.py tests simulated os.replace failure and validates that os.chmod with
Author
Owner

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

Clean-room verified (zero game data). Correct atomic staging cleanup on Windows read-only files (chmod 0o600 on replace failure in _write_json). Test passes (tests/test_world_names.py).

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/834#pullrequestreview-6041050046) · **approved these changes** Clean-room verified (zero game data). Correct atomic staging cleanup on Windows read-only files (chmod 0o600 on replace failure in _write_json). Test passes (tests/test_world_names.py).
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/834/head:github-bot/gh-834'
git switch 'github-bot/gh-834'

Merge

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