MCPcopy
hub / github.com/claude-code-best/claude-code / getExistingSessionFile

Method getExistingSessionFile

src/utils/sessionStorage.ts:1315–1337  ·  view source on GitHub ↗
(
    sessionId: UUID,
  )

Source from the content-addressed store, hash-verified

1313 */
1314 private existingSessionFiles = new Map<string, string>()
1315 private async getExistingSessionFile(
1316 sessionId: UUID,
1317 ): Promise<string | null> {
1318 const cached = this.existingSessionFiles.get(sessionId)
1319 if (cached) return cached
1320
1321 const targetFile = getTranscriptPathForSession(sessionId)
1322 try {
1323 await stat(targetFile)
1324 // Evict oldest entry when at capacity so the Map stays bounded
1325 if (this.existingSessionFiles.size >= MAX_CACHED_SESSION_FILES) {
1326 const oldestKey = this.existingSessionFiles.keys().next().value
1327 if (oldestKey !== undefined) {
1328 this.existingSessionFiles.delete(oldestKey)
1329 }
1330 }
1331 this.existingSessionFiles.set(sessionId, targetFile)
1332 return targetFile
1333 } catch (e) {
1334 if (isFsInaccessible(e)) return null
1335 throw e
1336 }
1337 }
1338
1339 private async persistToRemote(sessionId: UUID, entry: TranscriptMessage) {
1340 if (isShuttingDown()) {

Callers 1

appendEntryMethod · 0.95

Calls 8

statFunction · 0.85
isFsInaccessibleFunction · 0.85
nextMethod · 0.80
setMethod · 0.80
getMethod · 0.65
keysMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected