fix: clean up orphan build dirs from crashed runs#137
Draft
aiolibsbot wants to merge 3 commits into
Draft
Conversation
A crash between the rename and the final symlink-replace inside _atomic_replace_old_index leaves <target>-tmpXXXX directories (and sometimes -build symlinks) behind forever. Two changes: - Sweep matching siblings at startup while holding the lock; skip the one the live symlink points at. - rmtree(temp_dir, ignore_errors=True) in the failure handler so a partial replace (where temp_dir was already renamed) no longer raises FileNotFoundError and masks the original exception. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sweep leftover `-tmpXXXX` directories (and `-build` symlinks) at the start of `make_index`, and stop the failure handler from masking the real exception.
Why
The atomic-replace flow in `_atomic_replace_old_index` does rename → symlink → replace. A crash between those steps leaves a fully-built `-tmpXXXX` directory in place forever — there is no GC anywhere. Worse, the existing `except` handler calls `rmtree(temp_dir)` on a path that was already renamed, raising `FileNotFoundError` and masking the original exception.
How
Testing
🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 81 insertions(+), 2 deletions(-)
Code scan: clean
Tests: failed ([Errno 13] Permission denied: 'pytest')
Branch hygiene: 1 issue(s)
Generated by Kōan post-mission quality pipeline