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

Method appendLines

src/telemetry/index.ts:398–415  ·  view source on GitHub ↗
(lines: BufferLine[])

Source from the content-addressed store, hash-verified

396 }
397
398 private appendLines(lines: BufferLine[]): void {
399 try {
400 fs.mkdirSync(this.dir, { recursive: true, mode: 0o700 });
401 const payload = lines.map((l) => JSON.stringify(l)).join('\n') + '\n';
402 // Cap the buffer: drop oldest lines first (telemetry is best-effort —
403 // bounded disk use beats completeness).
404 let existing = '';
405 try { existing = fs.readFileSync(this.queuePath, 'utf8'); } catch { /* no queue yet */ }
406 let combined = existing + payload;
407 if (combined.length > MAX_BUFFER_BYTES) {
408 combined = combined.slice(combined.length - MAX_BUFFER_BYTES);
409 combined = combined.slice(combined.indexOf('\n') + 1); // drop the partial first line
410 }
411 fs.writeFileSync(this.queuePath, combined);
412 } catch {
413 /* fail silent */
414 }
415 }
416
417 /**
418 * Atomically claim the queue for sending (rename). Concurrent processes

Callers 2

flushNowMethod · 0.95
persistSyncMethod · 0.95

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected