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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user