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

Method acquire

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

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

Callers 3

recreateMethod · 0.95
withLockMethod · 0.95
withLockAsyncMethod · 0.95

Calls 1

tryAcquireMethod · 0.95

Tested by

no test coverage detected