MCPcopy Index your code
hub / github.com/codeaashu/claude-code / captureSnap

Function captureSnap

src/utils/sessionStoragePortable.ts:664–687  ·  view source on GitHub ↗
(
  s: LoadState,
  buf: Buffer,
  chunk: Buffer,
  lastSnapStart: number,
  lastSnapEnd: number,
)

Source from the content-addressed store, hash-verified

662
663// In-buf snap wins over straddle (later in file). carryBuf still valid here.
664function captureSnap(
665 s: LoadState,
666 buf: Buffer,
667 chunk: Buffer,
668 lastSnapStart: number,
669 lastSnapEnd: number,
670): void {
671 if (lastSnapStart !== -1) {
672 s.lastSnapLen = lastSnapEnd - lastSnapStart
673 if (s.lastSnapBuf === undefined || s.lastSnapLen > s.lastSnapBuf.length) {
674 s.lastSnapBuf = Buffer.allocUnsafe(s.lastSnapLen)
675 }
676 buf.copy(s.lastSnapBuf, 0, lastSnapStart, lastSnapEnd)
677 s.lastSnapSrc = s.lastSnapBuf
678 } else if (s.straddleSnapCarryLen > 0) {
679 s.lastSnapLen = s.straddleSnapCarryLen + s.straddleSnapTailEnd
680 if (s.lastSnapBuf === undefined || s.lastSnapLen > s.lastSnapBuf.length) {
681 s.lastSnapBuf = Buffer.allocUnsafe(s.lastSnapLen)
682 }
683 s.carryBuf!.copy(s.lastSnapBuf, 0, 0, s.straddleSnapCarryLen)
684 chunk.copy(s.lastSnapBuf, s.straddleSnapCarryLen, 0, s.straddleSnapTailEnd)
685 s.lastSnapSrc = s.lastSnapBuf
686 }
687}
688
689function captureCarry(s: LoadState, buf: Buffer, trailStart: number): void {
690 s.carryLen = buf.length - trailStart

Callers 1

readTranscriptForLoadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected