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

Method acquire

src/utils.ts:512–521  ·  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

510 * write as the only writer.
511 */
512 acquire(): void {
513 const refusal = this.tryAcquire(0);
514 if (refusal) {
515 const who = refusal.state === 'held' && refusal.pid !== undefined ? ` (PID ${refusal.pid})` : '';
516 throw new Error(
517 `CodeGraph database is locked by another process${who}. ` +
518 `If this is stale, run 'codegraph unlock' or delete ${this.lockPath}`
519 );
520 }
521 }
522
523 /** Null once the lock is ours; otherwise what kept us out. */
524 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