mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:20:44 +00:00
perf(plugins): cache runtime mirror file decisions
This commit is contained in:
@@ -183,10 +183,16 @@ export async function acquireFileLock(
|
||||
for (let attempt = 0; attempt <= options.retries.retries; attempt += 1) {
|
||||
try {
|
||||
const handle = await fs.open(lockPath, "wx");
|
||||
await handle.writeFile(
|
||||
JSON.stringify({ pid: process.pid, createdAt: new Date().toISOString() }, null, 2),
|
||||
"utf8",
|
||||
);
|
||||
try {
|
||||
await handle.writeFile(
|
||||
JSON.stringify({ pid: process.pid, createdAt: new Date().toISOString() }, null, 2),
|
||||
"utf8",
|
||||
);
|
||||
} catch (writeError) {
|
||||
await handle.close().catch(() => undefined);
|
||||
await fs.rm(lockPath, { force: true }).catch(() => undefined);
|
||||
throw writeError;
|
||||
}
|
||||
HELD_LOCKS.set(normalizedFile, { count: 1, handle, lockPath });
|
||||
return {
|
||||
lockPath,
|
||||
|
||||
Reference in New Issue
Block a user