mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:45:53 +01:00
[PR #731] fog_volumes: close mkstemp fd on fdopen error, use published_mode, and restore mode before unlink (FOG-VOLUMES-STAGE-CLEANUP) #769
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#769
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/731
Author: @trigger337
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/fog-volumes-stage-cleanup📝 Commits (1)
d8b4f4dfog_volumes: close mkstemp fd on fdopen error and restore mode before unlink (FOG-VOLUMES-STAGE-CLEANUP)📊 Changes
2 files changed (+86 additions, -2 deletions)
View changed files
📝
tests/test_fog_volumes.py(+76 -0)📝
tools/fog_volumes.py(+10 -2)📄 Description
Claimed in the coordination issue as: FOG-VOLUMES-STAGE-CLEANUP
https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7132211869
agent: yes
AI-assisted: yes
What and why
Hardens
tools/fog_volumes.pyatomic_write_json_atomicwhen publishing JSON summaries:mkstempfdonos.fdopenfailure: Wrapsos.fdopen(fd, ...)intry...except BaseException: os.close(fd); raiseso descriptors are never leaked if wrapping raises. On Windows, leavingfdopen causesos.unlink(tmp)in the cleanup handler to fail withPermissionError(sharing violation).published_mode: Importspublished_modefromfile_modeand callsos.chmod(tmp, published_mode(out_abs))before replace so the file retains expected destination permissions rather thanmkstemp's private0o600.BaseExceptionand restore writable mode beforeos.unlink: Changesexcept Exception:toexcept BaseException:(so KeyboardInterrupt does not strand staging files) and restoresos.chmod(tmp, 0o600)beforeos.unlink(tmp)so a failed replace over a read-only destination can be cleanly deleted on Windows.Adds regression tests in
tests/test_fog_volumes.py.Tested
Linux (CachyOS x86_64, Python 3.14):
python3 -m unittest tests/test_fog_volumes.py -v: 13 ran, OK (2 skipped).python3 scripts/check_no_game_data.py tools/fog_volumes.py tests/test_fog_volumes.py: clean (exit 0).python3 -m unittest tests/test_text_write_line_endings.py: 3/3 passed.python3 -m unittest tests/test_ci_registration.py: 15/15 passed.python3 -m compileall -q tools/fog_volumes.py tests/test_fog_volumes.py: clean.git diff --check: clean.Checklist
[✓] Based on current
mainand merges cleanly.[✓] One topic; follow-up work goes in a new pull request.
[✓] No game data, keys or decryption (CONTRIBUTING.md).
[ ] A new translator rule is in the contract table of
docs/design.md(n/a).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.