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

Function decodeLockInfo

src/mcp/daemon-paths.ts:117–140  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

115 * we treat such a lockfile as "process is unknown version, refuse to share."
116 */
117export function decodeLockInfo(raw: string): DaemonLockInfo | null {
118 const trimmed = raw.trim();
119 if (!trimmed) return null;
120 try {
121 const parsed = JSON.parse(trimmed);
122 if (
123 parsed &&
124 typeof parsed.pid === 'number' &&
125 typeof parsed.version === 'string' &&
126 typeof parsed.socketPath === 'string' &&
127 typeof parsed.startedAt === 'number'
128 ) {
129 return parsed as DaemonLockInfo;
130 }
131 return null;
132 } catch {
133 // Fall through to legacy plain-pid handling.
134 }
135 const pid = Number(trimmed);
136 if (Number.isFinite(pid) && pid > 0) {
137 return { pid, version: 'unknown', socketPath: '', startedAt: 0 };
138 }
139 return null;
140}

Callers 5

cleanupLockfileMethod · 0.90
tryAcquireDaemonLockFunction · 0.90
clearStaleDaemonLockFunction · 0.90
stopDaemonAtFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected