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

Function decodeLockInfo

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

Source from the content-addressed store, hash-verified

189 * we treat such a lockfile as "process is unknown version, refuse to share."
190 */
191export function decodeLockInfo(raw: string): DaemonLockInfo | null {
192 const trimmed = raw.trim();
193 if (!trimmed) return null;
194 try {
195 const parsed = JSON.parse(trimmed);
196 if (
197 parsed &&
198 typeof parsed.pid === 'number' &&
199 typeof parsed.version === 'string' &&
200 typeof parsed.socketPath === 'string' &&
201 typeof parsed.startedAt === 'number'
202 ) {
203 return parsed as DaemonLockInfo;
204 }
205 } catch {
206 // Fall through to legacy plain-pid handling.
207 }
208 if (!/^[1-9]\d*$/.test(trimmed)) return null;
209 const pid = Number(trimmed);
210 if (Number.isSafeInteger(pid)) {
211 return { pid, version: 'unknown', socketPath: '', startedAt: 0 };
212 }
213 return null;
214}

Callers 12

projectGoneReasonFunction · 0.90
startMethod · 0.90
cleanupLockfileMethod · 0.90
tryAcquireDaemonLockFunction · 0.90
clearStaleDaemonLockFunction · 0.90
stopDaemonAtFunction · 0.90
daemonStopFailureMessageFunction · 0.90
stopOlderDaemonFunction · 0.90
makeFallbackEngineFunction · 0.90
outwaitCandidateFunction · 0.90

Calls 2

NumberInterface · 0.85
parseMethod · 0.80

Tested by

no test coverage detected