mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-18 21:01:19 -08:00
Make the console survive locked files and private handles, and start with Activities off
AI Assisted
This commit is contained in:
1 parent
c52244bee1
commit
2cb174ecf0
17 files changed
+160
-69
No files matched your search
@@ -130,7 +130,22 @@ export function markHandoffUsed(id, now = clock()) {
|
||||
const file = path.join(handoffsDir(), id + ".json");
|
||||
const tmp = `${file}.${process.pid}.tmp`;
|
||||
fs.writeFileSync(tmp, JSON.stringify(next, null, 2) + "\n");
|
||||
fs.renameSync(tmp, file);
|
||||
// Windows scanners hold transient locks: retry the rename, and never leave the temp file.
|
||||
for (let attempt = 0; ; attempt++) {
|
||||
try {
|
||||
fs.renameSync(tmp, file);
|
||||
break;
|
||||
} catch (err) {
|
||||
const transient = err.code === "EPERM" || err.code === "EBUSY" || err.code === "EACCES";
|
||||
if (!transient || attempt >= 3) {
|
||||
try {
|
||||
fs.rmSync(tmp, { force: true });
|
||||
} catch {}
|
||||
throw err;
|
||||
}
|
||||
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 40 * (attempt + 1));
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user