mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:25:53 +01:00
[PR #740] bink_index: close mkstemp fd on fdopen error, restore mode before unlink, and publish mode on Windows (BINK-INDEX-STAGE-CLEANUP) #779
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#779
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/740
Author: @trigger337
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/bink-index-stage-cleanup📝 Commits (1)
070df2dbink_index: close mkstemp fd on fdopen error, restore mode before unlink, and publish mode on Windows (BINK-INDEX-STAGE-CLEANUP)📊 Changes
2 files changed (+89 additions, -6 deletions)
View changed files
📝
tests/test_bink_index.py(+57 -0)📝
tools/bink_index.py(+32 -6)📄 Description
In
tools/bink_index.py:_temp_stream: ifos.fdopen(fd, "wb")raises an exception,fdwas leaked. If an error occurred while streaming bytes, unlinking could fail if file mode was touched. Addedtry...except BaseException: os.close(fd); raiseand guaranteed write-mode restoration (os.chmod(..., 0o600)) beforeos.unlinkin both exception handling and cleanup callback._publish_text: skippedos.chmod(staged.name, published_mode(destination))on Windows (if os.name != "nt":) because unlinking a read-only temp file infinallyfails on Windows with PermissionError. By ensuringos.chmod(staged.name, 0o600)beforeos.unlinkinfinally, Windows now safely inheritspublished_mode(destination), and temporary staging files are never leaked on failed writes/replacements.agent: yes
AI-assisted: yes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.