@buda-ai/connector 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +14 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,8 +25,8 @@ async function acquireExclusiveFileLock(targetPath, options = {}) {
|
|
|
25
25
|
} catch (error) {
|
|
26
26
|
if (!isAlreadyExists(error)) throw error;
|
|
27
27
|
if (await shouldRecoverLock(lockPath, staleMs)) {
|
|
28
|
-
await unlink(lockPath).catch(() =>
|
|
29
|
-
continue;
|
|
28
|
+
const recovered = await unlink(lockPath).then(() => true).catch(() => false);
|
|
29
|
+
if (recovered) continue;
|
|
30
30
|
}
|
|
31
31
|
if (Date.now() >= deadline) {
|
|
32
32
|
throw new Error(`Timed out waiting for exclusive access to ${targetPath}`);
|
|
@@ -35,17 +35,23 @@ async function acquireExclusiveFileLock(targetPath, options = {}) {
|
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
37
|
const ownerToken = randomUUID();
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
try {
|
|
39
|
+
await handle.writeFile(
|
|
40
|
+
`${JSON.stringify({ pid: process.pid, ownerToken, createdAt: Date.now() })}
|
|
40
41
|
`
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
);
|
|
43
|
+
await handle.sync();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
await handle.close().catch(() => void 0);
|
|
46
|
+
await unlink(lockPath).catch(() => void 0);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
await handle.close();
|
|
43
50
|
let released = false;
|
|
44
51
|
return {
|
|
45
52
|
release: async () => {
|
|
46
53
|
if (released) return;
|
|
47
54
|
released = true;
|
|
48
|
-
await handle.close();
|
|
49
55
|
const currentOwner = await readFile(lockPath, "utf8").then((raw) => JSON.parse(raw).ownerToken).catch(() => void 0);
|
|
50
56
|
if (currentOwner === ownerToken) await unlink(lockPath).catch(() => void 0);
|
|
51
57
|
}
|
|
@@ -517,7 +523,7 @@ import path2 from "path";
|
|
|
517
523
|
// package.json
|
|
518
524
|
var package_default = {
|
|
519
525
|
name: "@buda-ai/connector",
|
|
520
|
-
version: "0.1.
|
|
526
|
+
version: "0.1.24",
|
|
521
527
|
private: false,
|
|
522
528
|
type: "module",
|
|
523
529
|
publishConfig: {
|