From 693e05a603e3b33e9496c1b7819fdb46010a8f3b Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Fri, 3 Apr 2026 11:49:37 -0400 Subject: [PATCH] fix: only remove session tmp dir when last pointer file is cleared (#1593) Explicitly check that the directory is empty before removing it rather than relying on rmdirSync throwing ENOTEMPTY when siblings remain. On Windows that error is not raised reliably, causing the session tmp directory to be deleted prematurely when sibling pointer files exist. Co-Authored-By: Claude Sonnet 4.6 --- get-shit-done/bin/lib/core.cjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/get-shit-done/bin/lib/core.cjs b/get-shit-done/bin/lib/core.cjs index faa488adf..041d6557a 100644 --- a/get-shit-done/bin/lib/core.cjs +++ b/get-shit-done/bin/lib/core.cjs @@ -714,8 +714,15 @@ function clearActiveWorkstreamPointer(filePath, cleanupDirPath) { // Session-scoped pointers for a repo share one tmp directory. Only remove it // when it is empty so clearing or self-healing one session never deletes siblings. + // Explicitly check remaining entries rather than relying on rmdirSync throwing + // ENOTEMPTY — that error is not raised reliably on Windows. if (cleanupDirPath) { - try { fs.rmdirSync(cleanupDirPath); } catch {} + try { + const remaining = fs.readdirSync(cleanupDirPath); + if (remaining.length === 0) { + fs.rmdirSync(cleanupDirPath); + } + } catch {} } }