fix: clean up partial clone artifacts when git clone fails (#634)#880
fix: clean up partial clone artifacts when git clone fails (#634)#880MrLawrenceKwan wants to merge 1 commit into
Conversation
When GitHub (or any git remote) is unavailable and clone_repository raises pygit2.GitError, the partially created repo directory was left behind with broken symlinks and incomplete files. On subsequent sync attempts, _discover_repository would find these artifacts, leading to an accumulation of broken symlinks in the filesystem. This fix removes the partial clone directory when a clone fails, preventing broken symlinks from accumulating. Fixes permitio#634
✅ Deploy Preview for opal-docs canceled.
|
|
Hi maintainers 👋 Friendly follow-up — this fix is a small 7-line change and all CI checks have passed. Would love to get this reviewed when you have a moment. Let me know if any changes are needed. Thanks! |
|
Thanks for this fix, @MrLawrenceKwan — the diagnosis is exactly right: |
Problem
When GitHub (or any git remote) is unavailable and
clone_repositoryraisespygit2.GitError, the partially created repo directory is left behind with broken symlinks and incomplete files. On subsequent sync attempts, these artifacts accumulate in the filesystem, appearing as zombie-like processes in/proc.Root Cause
In
git_fetcher.py, the_clone()method catchespygit2.GitErrorbut does not clean up the partially-created repo directory atself._repo_path. The directory may contain broken symlinks and incomplete git objects from the interrupted clone.Fix
Added cleanup of the partial clone directory when
pygit2.GitErroris caught in_clone(). Usesshutil.rmtree(path, ignore_errors=True)to safely remove any residual files.Changes
packages/opal-server/opal_server/git_fetcher.pyThis is a minimal, surgical fix — no other files or logic are modified.
Fixes #634