Clean up leaked tmp_pack files after failed status refresh#2026
Clean up leaked tmp_pack files after failed status refresh#2026SAKETH11111 wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughImplement cleanup mechanism for leaked temporary pack files created during failed git fetch operations. Records existing Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved This is a straightforward bug fix that adds cleanup of leaked temporary git pack files after failed fetch operations. The change is well-isolated, includes appropriate safety checks (concurrent fetch lock detection), and has comprehensive test coverage for the new behavior. It only affects error paths and doesn't modify normal operation. You can customize Macroscope's approvability policy. Learn more. |
|
@codex review |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0d5ee6bc9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Closes #1965
What was broken
Background git status refreshes could time out and leave new
tmp_pack_*files behind in.git/objects/pack.Repeated failures could accumulate those temporary pack files until the repository disk usage became destructive.
Root cause
The background upstream refresh path stopped at the failed fetch result and never cleaned up temp pack artifacts created by that refresh attempt.
What changed
tmp_pack_*files before each background refresh fetchtmp_pack_*files when that refresh failsFETCH_HEAD.lockindicates another fetch is activeValidation
bun fmtbun lintbun run --cwd apps/server test src/git/Layers/GitCore.test.tsRepo-wide
bun typecheckis currently failing in untouchedapps/server/src/provider/Layers/ClaudeAdapter.tson this branch base, so I did not widen this bugfix PR to include unrelated provider changes.Note
Clean up leaked
tmp_pack_files after failed git fetch during status refreshfetchRemoteForStatus, anytmp_pack_*files created during the failed fetch are removed fromobjects/packFETCH_HEAD.lockexists in the main git dir or any linked worktree, indicating a concurrent fetch is in progressTEMPORARY_PACK_FILE_PREFIXconstant and helper functions:readTemporaryPackFiles,listFetchHeadLockPaths,hasConcurrentFetchLock, andremoveLeakedTemporaryPackFilesin GitCore.tstmp_pack_*files and non-temporary pack files are preservedfetchRemoteForStatusno longer passesallowNonZeroExitand now uses afallbackErrorMessagefor the fetch callMacroscope summarized 622083d.
Note
Medium Risk
Adds filesystem cleanup and lock detection around background
git fetchduringstatusDetails, which could accidentally remove files or behave incorrectly under unusual repo layouts/concurrent operations if the heuristics are wrong.Overview
Prevents disk bloat from failed background upstream refreshes by snapshotting pre-existing
.git/objects/pack/tmp_pack_*files before the refreshgit fetchand deleting only newly createdtmp_pack_*artifacts when the fetch fails.Cleanup is skipped when
FETCH_HEAD.lockis present in the main repo or any linked worktree (indicating another fetch is in progress), and new tests cover both the cleanup behavior and the lock-guard scenarios.Reviewed by Cursor Bugbot for commit 622083d. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
Tests