@elaraai/e3-core 0.0.2-beta.5 → 0.0.2-beta.50
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/README.md +25 -22
- package/dist/src/dataflow/api-compat.d.ts +90 -0
- package/dist/src/dataflow/api-compat.d.ts.map +1 -0
- package/dist/src/dataflow/api-compat.js +139 -0
- package/dist/src/dataflow/api-compat.js.map +1 -0
- package/dist/src/dataflow/index.d.ts +18 -0
- package/dist/src/dataflow/index.d.ts.map +1 -0
- package/dist/src/dataflow/index.js +23 -0
- package/dist/src/dataflow/index.js.map +1 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts +76 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.js +729 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.js.map +1 -0
- package/dist/src/dataflow/orchestrator/index.d.ts +12 -0
- package/dist/src/dataflow/orchestrator/index.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/index.js +12 -0
- package/dist/src/dataflow/orchestrator/index.js.map +1 -0
- package/dist/src/dataflow/orchestrator/interfaces.d.ts +163 -0
- package/dist/src/dataflow/orchestrator/interfaces.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/interfaces.js +52 -0
- package/dist/src/dataflow/orchestrator/interfaces.js.map +1 -0
- package/dist/src/dataflow/state-store/FileStateStore.d.ts +67 -0
- package/dist/src/dataflow/state-store/FileStateStore.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/FileStateStore.js +300 -0
- package/dist/src/dataflow/state-store/FileStateStore.js.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts +42 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.js +229 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.js.map +1 -0
- package/dist/src/dataflow/state-store/index.d.ts +13 -0
- package/dist/src/dataflow/state-store/index.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/index.js +13 -0
- package/dist/src/dataflow/state-store/index.js.map +1 -0
- package/dist/src/dataflow/state-store/interfaces.d.ts +159 -0
- package/dist/src/dataflow/state-store/interfaces.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/interfaces.js +6 -0
- package/dist/src/dataflow/state-store/interfaces.js.map +1 -0
- package/dist/src/dataflow/steps.d.ts +222 -0
- package/dist/src/dataflow/steps.d.ts.map +1 -0
- package/dist/src/dataflow/steps.js +707 -0
- package/dist/src/dataflow/steps.js.map +1 -0
- package/dist/src/dataflow/types.d.ts +127 -0
- package/dist/src/dataflow/types.d.ts.map +1 -0
- package/dist/src/dataflow/types.js +7 -0
- package/dist/src/dataflow/types.js.map +1 -0
- package/dist/src/dataflow.d.ts +113 -38
- package/dist/src/dataflow.d.ts.map +1 -1
- package/dist/src/dataflow.js +269 -416
- package/dist/src/dataflow.js.map +1 -1
- package/dist/src/dataset-refs.d.ts +124 -0
- package/dist/src/dataset-refs.d.ts.map +1 -0
- package/dist/src/dataset-refs.js +319 -0
- package/dist/src/dataset-refs.js.map +1 -0
- package/dist/src/errors.d.ts +39 -9
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +51 -8
- package/dist/src/errors.js.map +1 -1
- package/dist/src/execution/LocalTaskRunner.d.ts +73 -0
- package/dist/src/execution/LocalTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/LocalTaskRunner.js +399 -0
- package/dist/src/execution/LocalTaskRunner.js.map +1 -0
- package/dist/src/execution/MockTaskRunner.d.ts +49 -0
- package/dist/src/execution/MockTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/MockTaskRunner.js +54 -0
- package/dist/src/execution/MockTaskRunner.js.map +1 -0
- package/dist/src/execution/index.d.ts +16 -0
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +8 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/interfaces.d.ts +246 -0
- package/dist/src/execution/interfaces.d.ts.map +1 -0
- package/dist/src/execution/interfaces.js +6 -0
- package/dist/src/execution/interfaces.js.map +1 -0
- package/dist/src/execution/processHelpers.d.ts +20 -0
- package/dist/src/execution/processHelpers.d.ts.map +1 -0
- package/dist/src/execution/processHelpers.js +62 -0
- package/dist/src/execution/processHelpers.js.map +1 -0
- package/dist/src/executions.d.ts +71 -104
- package/dist/src/executions.d.ts.map +1 -1
- package/dist/src/executions.js +110 -476
- package/dist/src/executions.js.map +1 -1
- package/dist/src/index.d.ts +20 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +48 -18
- package/dist/src/index.js.map +1 -1
- package/dist/src/objects.d.ts +7 -53
- package/dist/src/objects.d.ts.map +1 -1
- package/dist/src/objects.js +13 -232
- package/dist/src/objects.js.map +1 -1
- package/dist/src/packages.d.ts +41 -14
- package/dist/src/packages.d.ts.map +1 -1
- package/dist/src/packages.js +145 -88
- package/dist/src/packages.js.map +1 -1
- package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts +35 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.js +107 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.js.map +1 -0
- package/dist/src/storage/in-memory/InMemoryStorage.d.ts +139 -0
- package/dist/src/storage/in-memory/InMemoryStorage.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryStorage.js +439 -0
- package/dist/src/storage/in-memory/InMemoryStorage.js.map +1 -0
- package/dist/src/storage/in-memory/index.d.ts +12 -0
- package/dist/src/storage/in-memory/index.d.ts.map +1 -0
- package/dist/src/storage/in-memory/index.js +12 -0
- package/dist/src/storage/in-memory/index.js.map +1 -0
- package/dist/src/storage/index.d.ts +18 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +10 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +581 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -0
- package/dist/src/storage/interfaces.js +6 -0
- package/dist/src/storage/interfaces.js.map +1 -0
- package/dist/src/storage/local/LocalBackend.d.ts +56 -0
- package/dist/src/storage/local/LocalBackend.d.ts.map +1 -0
- package/dist/src/storage/local/LocalBackend.js +145 -0
- package/dist/src/storage/local/LocalBackend.js.map +1 -0
- package/dist/src/storage/local/LocalDatasetRefStore.d.ts +22 -0
- package/dist/src/storage/local/LocalDatasetRefStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalDatasetRefStore.js +118 -0
- package/dist/src/storage/local/LocalDatasetRefStore.js.map +1 -0
- package/dist/src/storage/local/LocalLockService.d.ts +111 -0
- package/dist/src/storage/local/LocalLockService.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLockService.js +364 -0
- package/dist/src/storage/local/LocalLockService.js.map +1 -0
- package/dist/src/storage/local/LocalLogStore.d.ts +23 -0
- package/dist/src/storage/local/LocalLogStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLogStore.js +66 -0
- package/dist/src/storage/local/LocalLogStore.js.map +1 -0
- package/dist/src/storage/local/LocalObjectStore.d.ts +55 -0
- package/dist/src/storage/local/LocalObjectStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalObjectStore.js +300 -0
- package/dist/src/storage/local/LocalObjectStore.js.map +1 -0
- package/dist/src/storage/local/LocalRefStore.d.ts +50 -0
- package/dist/src/storage/local/LocalRefStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRefStore.js +337 -0
- package/dist/src/storage/local/LocalRefStore.js.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.d.ts +55 -0
- package/dist/src/storage/local/LocalRepoStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.js +365 -0
- package/dist/src/storage/local/LocalRepoStore.js.map +1 -0
- package/dist/src/storage/local/gc.d.ts +92 -0
- package/dist/src/storage/local/gc.d.ts.map +1 -0
- package/dist/src/storage/local/gc.js +377 -0
- package/dist/src/storage/local/gc.js.map +1 -0
- package/dist/src/storage/local/index.d.ts +18 -0
- package/dist/src/storage/local/index.d.ts.map +1 -0
- package/dist/src/storage/local/index.js +18 -0
- package/dist/src/storage/local/index.js.map +1 -0
- package/dist/src/storage/local/localHelpers.d.ts +25 -0
- package/dist/src/storage/local/localHelpers.d.ts.map +1 -0
- package/dist/src/storage/local/localHelpers.js +69 -0
- package/dist/src/storage/local/localHelpers.js.map +1 -0
- package/dist/src/{repository.d.ts → storage/local/repository.d.ts} +8 -4
- package/dist/src/storage/local/repository.d.ts.map +1 -0
- package/dist/src/{repository.js → storage/local/repository.js} +31 -29
- package/dist/src/storage/local/repository.js.map +1 -0
- package/dist/src/tasks.d.ts +16 -10
- package/dist/src/tasks.d.ts.map +1 -1
- package/dist/src/tasks.js +35 -41
- package/dist/src/tasks.js.map +1 -1
- package/dist/src/test-helpers.d.ts +5 -4
- package/dist/src/test-helpers.d.ts.map +1 -1
- package/dist/src/test-helpers.js +9 -21
- package/dist/src/test-helpers.js.map +1 -1
- package/dist/src/transfer/InMemoryTransferBackend.d.ts +75 -0
- package/dist/src/transfer/InMemoryTransferBackend.d.ts.map +1 -0
- package/dist/src/transfer/InMemoryTransferBackend.js +211 -0
- package/dist/src/transfer/InMemoryTransferBackend.js.map +1 -0
- package/dist/src/transfer/index.d.ts +9 -0
- package/dist/src/transfer/index.d.ts.map +1 -0
- package/dist/src/transfer/index.js +11 -0
- package/dist/src/transfer/index.js.map +1 -0
- package/dist/src/transfer/interfaces.d.ts +103 -0
- package/dist/src/transfer/interfaces.d.ts.map +1 -0
- package/dist/src/transfer/interfaces.js +6 -0
- package/dist/src/transfer/interfaces.js.map +1 -0
- package/dist/src/transfer/process.d.ts +55 -0
- package/dist/src/transfer/process.d.ts.map +1 -0
- package/dist/src/transfer/process.js +144 -0
- package/dist/src/transfer/process.js.map +1 -0
- package/dist/src/transfer/types.d.ts +106 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/transfer/types.js +61 -0
- package/dist/src/transfer/types.js.map +1 -0
- package/dist/src/trees.d.ts +147 -59
- package/dist/src/trees.d.ts.map +1 -1
- package/dist/src/trees.js +372 -419
- package/dist/src/trees.js.map +1 -1
- package/dist/src/uuid.d.ts +26 -0
- package/dist/src/uuid.d.ts.map +1 -0
- package/dist/src/uuid.js +80 -0
- package/dist/src/uuid.js.map +1 -0
- package/dist/src/workspaceStatus.d.ts +6 -4
- package/dist/src/workspaceStatus.d.ts.map +1 -1
- package/dist/src/workspaceStatus.js +46 -60
- package/dist/src/workspaceStatus.js.map +1 -1
- package/dist/src/workspaces.d.ts +46 -47
- package/dist/src/workspaces.d.ts.map +1 -1
- package/dist/src/workspaces.js +281 -221
- package/dist/src/workspaces.js.map +1 -1
- package/package.json +4 -4
- package/dist/src/gc.d.ts +0 -54
- package/dist/src/gc.d.ts.map +0 -1
- package/dist/src/gc.js +0 -233
- package/dist/src/gc.js.map +0 -1
- package/dist/src/repository.d.ts.map +0 -1
- package/dist/src/repository.js.map +0 -1
- package/dist/src/workspaceLock.d.ts +0 -67
- package/dist/src/workspaceLock.d.ts.map +0 -1
- package/dist/src/workspaceLock.js +0 -217
- package/dist/src/workspaceLock.js.map +0 -1
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
-
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Workspace locking for safe concurrent access.
|
|
7
|
-
*
|
|
8
|
-
* Provides exclusive locks on workspaces to prevent concurrent dataflow
|
|
9
|
-
* executions or writes that could corrupt workspace state. Uses Linux
|
|
10
|
-
* flock() for automatic lock release on process death.
|
|
11
|
-
*
|
|
12
|
-
* Lock mechanism:
|
|
13
|
-
* - Uses flock(LOCK_EX | LOCK_NB) via the `flock` command for kernel-managed locking
|
|
14
|
-
* - Lock is automatically released when the process dies (kernel handles this)
|
|
15
|
-
* - Metadata (PID, bootId, startTime) written to lock file for diagnostics
|
|
16
|
-
* - Stale lock detection via bootId comparison (handles system restarts)
|
|
17
|
-
*/
|
|
18
|
-
import * as fs from 'fs/promises';
|
|
19
|
-
import * as path from 'path';
|
|
20
|
-
import { spawn } from 'child_process';
|
|
21
|
-
import { WorkspaceLockError } from './errors.js';
|
|
22
|
-
import { getBootId, getPidStartTime, isProcessAlive } from './executions.js';
|
|
23
|
-
/**
|
|
24
|
-
* Get the lock file path for a workspace.
|
|
25
|
-
*/
|
|
26
|
-
export function workspaceLockPath(repoPath, workspace) {
|
|
27
|
-
return path.join(repoPath, 'workspaces', `${workspace}.lock`);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Read lock metadata from a lock file.
|
|
31
|
-
* Returns null if file doesn't exist or is invalid.
|
|
32
|
-
*/
|
|
33
|
-
async function readLockMetadata(lockPath) {
|
|
34
|
-
try {
|
|
35
|
-
const data = await fs.readFile(lockPath, 'utf-8');
|
|
36
|
-
return JSON.parse(data);
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Convert internal metadata to public LockHolder interface.
|
|
44
|
-
*/
|
|
45
|
-
function metadataToHolder(metadata) {
|
|
46
|
-
return {
|
|
47
|
-
pid: metadata.pid,
|
|
48
|
-
acquiredAt: metadata.acquiredAt,
|
|
49
|
-
bootId: metadata.bootId,
|
|
50
|
-
startTime: metadata.startTime,
|
|
51
|
-
command: metadata.command,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
// =============================================================================
|
|
55
|
-
// Lock Acquisition
|
|
56
|
-
// =============================================================================
|
|
57
|
-
/**
|
|
58
|
-
* Acquire an exclusive lock on a workspace.
|
|
59
|
-
*
|
|
60
|
-
* Uses Linux flock() for kernel-managed locking. The lock is automatically
|
|
61
|
-
* released when the process exits (even on crash/kill).
|
|
62
|
-
*
|
|
63
|
-
* @param repoPath - Path to .e3 repository
|
|
64
|
-
* @param workspace - Workspace name to lock
|
|
65
|
-
* @param options - Lock acquisition options
|
|
66
|
-
* @returns Lock handle - call release() when done
|
|
67
|
-
* @throws {WorkspaceLockError} If workspace is locked by another process
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const lock = await acquireWorkspaceLock(repoPath, 'production');
|
|
72
|
-
* try {
|
|
73
|
-
* await dataflowExecute(repoPath, 'production', { lock });
|
|
74
|
-
* } finally {
|
|
75
|
-
* await lock.release();
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
export async function acquireWorkspaceLock(repoPath, workspace, options = {}) {
|
|
80
|
-
const lockPath = workspaceLockPath(repoPath, workspace);
|
|
81
|
-
// Ensure workspaces directory exists
|
|
82
|
-
await fs.mkdir(path.dirname(lockPath), { recursive: true });
|
|
83
|
-
// Gather our process identification
|
|
84
|
-
const pid = process.pid;
|
|
85
|
-
const bootId = await getBootId();
|
|
86
|
-
const startTime = await getPidStartTime(pid);
|
|
87
|
-
const command = process.argv.join(' ');
|
|
88
|
-
const acquiredAt = new Date().toISOString();
|
|
89
|
-
const metadata = { pid, bootId, startTime, acquiredAt, command };
|
|
90
|
-
// Try to acquire flock via subprocess
|
|
91
|
-
// The subprocess holds the lock and we communicate with it via stdin/signals
|
|
92
|
-
const flockProcess = await tryAcquireFlock(lockPath, metadata, options);
|
|
93
|
-
if (!flockProcess) {
|
|
94
|
-
// Failed to acquire - read metadata to report who has it
|
|
95
|
-
const existingMetadata = await readLockMetadata(lockPath);
|
|
96
|
-
const holder = existingMetadata ? metadataToHolder(existingMetadata) : undefined;
|
|
97
|
-
throw new WorkspaceLockError(workspace, holder);
|
|
98
|
-
}
|
|
99
|
-
// Lock acquired! Create handle
|
|
100
|
-
let released = false;
|
|
101
|
-
const handle = {
|
|
102
|
-
workspace,
|
|
103
|
-
lockPath,
|
|
104
|
-
async release() {
|
|
105
|
-
if (released)
|
|
106
|
-
return;
|
|
107
|
-
released = true;
|
|
108
|
-
// Kill the flock subprocess to release the lock
|
|
109
|
-
flockProcess.kill('SIGTERM');
|
|
110
|
-
// Clean up lock file (best effort)
|
|
111
|
-
try {
|
|
112
|
-
await fs.unlink(lockPath);
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
// Ignore - file might already be gone
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
return handle;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Try to acquire flock using a subprocess.
|
|
123
|
-
*
|
|
124
|
-
* We spawn `flock --nonblock <lockfile> cat` which:
|
|
125
|
-
* 1. Tries to acquire exclusive lock (non-blocking)
|
|
126
|
-
* 2. If successful, runs `cat` which blocks reading stdin forever
|
|
127
|
-
* 3. We keep the subprocess alive to hold the lock
|
|
128
|
-
* 4. When we kill the subprocess, the lock is released
|
|
129
|
-
*
|
|
130
|
-
* Returns the subprocess if lock acquired, null if lock is held by another.
|
|
131
|
-
*/
|
|
132
|
-
async function tryAcquireFlock(lockPath, metadata, options) {
|
|
133
|
-
// First, check if there's a stale lock we can clean up
|
|
134
|
-
await checkAndCleanStaleLock(lockPath);
|
|
135
|
-
const args = options.wait
|
|
136
|
-
? ['--timeout', String((options.timeout ?? 30000) / 1000), lockPath, 'cat']
|
|
137
|
-
: ['--nonblock', lockPath, 'cat'];
|
|
138
|
-
const child = spawn('flock', args, {
|
|
139
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
140
|
-
detached: false,
|
|
141
|
-
});
|
|
142
|
-
return new Promise((resolve) => {
|
|
143
|
-
let resolved = false;
|
|
144
|
-
// If flock fails to acquire, it exits with code 1
|
|
145
|
-
child.on('error', () => {
|
|
146
|
-
if (!resolved) {
|
|
147
|
-
resolved = true;
|
|
148
|
-
resolve(null);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
child.on('exit', () => {
|
|
152
|
-
if (!resolved) {
|
|
153
|
-
resolved = true;
|
|
154
|
-
// Exit code 1 means lock is held by another
|
|
155
|
-
resolve(null);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
// Give flock a moment to either acquire or fail
|
|
159
|
-
// If it's still running after 100ms, we have the lock
|
|
160
|
-
setTimeout(() => {
|
|
161
|
-
if (!resolved && !child.killed && child.exitCode === null) {
|
|
162
|
-
resolved = true;
|
|
163
|
-
// Write metadata to lock file now that we have the lock
|
|
164
|
-
// Use void to explicitly ignore the promise (metadata is informational only)
|
|
165
|
-
void fs.writeFile(lockPath, JSON.stringify(metadata, null, 2)).catch(() => { });
|
|
166
|
-
resolve(child);
|
|
167
|
-
}
|
|
168
|
-
}, 100);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Check if a lock file exists with stale metadata and clean it up.
|
|
173
|
-
* A lock is stale if the holder process no longer exists.
|
|
174
|
-
*/
|
|
175
|
-
async function checkAndCleanStaleLock(lockPath) {
|
|
176
|
-
const metadata = await readLockMetadata(lockPath);
|
|
177
|
-
if (!metadata)
|
|
178
|
-
return;
|
|
179
|
-
// Check if the process that created this lock is still alive
|
|
180
|
-
const alive = await isProcessAlive(metadata.pid, metadata.startTime, metadata.bootId);
|
|
181
|
-
if (!alive) {
|
|
182
|
-
// Stale lock - try to remove it
|
|
183
|
-
try {
|
|
184
|
-
await fs.unlink(lockPath);
|
|
185
|
-
}
|
|
186
|
-
catch {
|
|
187
|
-
// Ignore - another process might have cleaned it up
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Check if a workspace is currently locked.
|
|
193
|
-
*
|
|
194
|
-
* @param repoPath - Path to .e3 repository
|
|
195
|
-
* @param workspace - Workspace name to check
|
|
196
|
-
* @returns Lock holder info if locked, null if not locked
|
|
197
|
-
*/
|
|
198
|
-
export async function getWorkspaceLockHolder(repoPath, workspace) {
|
|
199
|
-
const lockPath = workspaceLockPath(repoPath, workspace);
|
|
200
|
-
const metadata = await readLockMetadata(lockPath);
|
|
201
|
-
if (!metadata)
|
|
202
|
-
return null;
|
|
203
|
-
// Check if the holder is still alive
|
|
204
|
-
const alive = await isProcessAlive(metadata.pid, metadata.startTime, metadata.bootId);
|
|
205
|
-
if (!alive) {
|
|
206
|
-
// Stale lock - clean it up and report as not locked
|
|
207
|
-
try {
|
|
208
|
-
await fs.unlink(lockPath);
|
|
209
|
-
}
|
|
210
|
-
catch {
|
|
211
|
-
// Ignore
|
|
212
|
-
}
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
return metadataToHolder(metadata);
|
|
216
|
-
}
|
|
217
|
-
//# sourceMappingURL=workspaceLock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspaceLock.js","sourceRoot":"","sources":["../../src/workspaceLock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAqB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAmB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA8C7E;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,SAAiB;IACnE,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,SAAS,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,gBAAgB,CAAC,QAAgB;IAC9C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,KA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