From dbbfa6798f45917cf716ea68d81528f53a1be80e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 23 Jun 2026 21:20:03 +0000 Subject: [PATCH] Check gc.pid in addition to FETCH_HEAD.lock before cleaning temp packs The removeNewTemporaryPackFiles cleanup used a set-difference that could capture tmp_pack_* files created by concurrent git operations (e.g. git gc, git repack) that don't hold FETCH_HEAD.lock. Expand the lock check to also detect gc.pid, which git gc creates for the duration of garbage collection. --- apps/server/src/vcs/GitVcsDriverCore.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.ts index 77e9427063..833d96aa84 100644 --- a/apps/server/src/vcs/GitVcsDriverCore.ts +++ b/apps/server/src/vcs/GitVcsDriverCore.ts @@ -968,7 +968,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* ]; }); - const hasActiveFetchLock = Effect.fn("GitVcsDriver.hasActiveFetchLock")(function* ( + const hasActiveGitPackLock = Effect.fn("GitVcsDriver.hasActiveGitPackLock")(function* ( gitCommonDir: string, ): Effect.fn.Return { const lockPaths = yield* listFetchHeadLockPaths(gitCommonDir); @@ -988,6 +988,14 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* return true; } } + const gcPidExists = yield* fileSystem.exists(path.join(gitCommonDir, "gc.pid")).pipe( + Effect.catchTags({ + PlatformError: () => Effect.succeed(false), + }), + ); + if (gcPidExists) { + return true; + } return false; }); @@ -1004,13 +1012,10 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* if (newFiles.length === 0) { return; } - if (yield* hasActiveFetchLock(gitCommonDir)) { - yield* Effect.logWarning( - "Skipped temporary Git pack cleanup while a fetch lock is active", - { - temporaryPackCount: newFiles.length, - }, - ); + if (yield* hasActiveGitPackLock(gitCommonDir)) { + yield* Effect.logWarning("Skipped temporary Git pack cleanup while a git lock is active", { + temporaryPackCount: newFiles.length, + }); return; }