MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / readSessionLite

Function readSessionLite

source code/utils/sessionStoragePortable.ts:258–284  ·  view source on GitHub ↗
(
  filePath: string,
)

Source from the content-addressed store, hash-verified

256 * Returns null on any error.
257 */
258export async function readSessionLite(
259 filePath: string,
260): Promise<LiteSessionFile | null> {
261 try {
262 const fh = await fsOpen(filePath, 'r')
263 try {
264 const stat = await fh.stat()
265 const buf = Buffer.allocUnsafe(LITE_READ_BUF_SIZE)
266 const headResult = await fh.read(buf, 0, LITE_READ_BUF_SIZE, 0)
267 if (headResult.bytesRead === 0) return null
268
269 const head = buf.toString('utf8', 0, headResult.bytesRead)
270 const tailOffset = Math.max(0, stat.size - LITE_READ_BUF_SIZE)
271 let tail = head
272 if (tailOffset > 0) {
273 const tailResult = await fh.read(buf, 0, LITE_READ_BUF_SIZE, tailOffset)
274 tail = buf.toString('utf8', 0, tailResult.bytesRead)
275 }
276
277 return { mtime: stat.mtime.getTime(), size: stat.size, head, tail }
278 } finally {
279 await fh.close()
280 }
281 } catch {
282 return null
283 }
284}
285
286// ---------------------------------------------------------------------------
287// Path sanitization

Callers 1

readCandidateFunction · 0.85

Calls 4

maxMethod · 0.80
toStringMethod · 0.65
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected