MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / acquire

Method acquire

src/utils.ts:488–497  ·  view source on GitHub ↗

* Acquire the lock. Throws if the lock is held by another live process. * * A free lock costs one create. A stale one, whose PID is dead or missing, * is replaced only by the process holding ` .break` (itself a * FileLock), after reading it again there (#2979). Before, two processes

()

Source from the content-addressed store, hash-verified

486 * write as the only writer.
487 */
488 acquire(): void {
489 const refusal = this.tryAcquire(0);
490 if (refusal) {
491 const who = refusal.state === 'held' && refusal.pid !== undefined ? ` (PID ${refusal.pid})` : '';
492 throw new Error(
493 `CodeGraph database is locked by another process${who}. ` +
494 `If this is stale, run 'codegraph unlock' or delete ${this.lockPath}`
495 );
496 }
497 }
498
499 /** Null once the lock is ours; otherwise what kept us out. */
500 private tryAcquire(depth: number): LockHolder | null {

Callers 2

withLockMethod · 0.95
withLockAsyncMethod · 0.95

Calls 1

tryAcquireMethod · 0.95

Tested by

no test coverage detected