MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / writeStateAtomic

Function writeStateAtomic

src/utils/cacheStats.ts:96–109  ·  view source on GitHub ↗
(
  filePath: string,
  state: CacheStatsState,
)

Source from the content-addressed store, hash-verified

94 * partial-write corruption and concurrent reads.
95 */
96export async function writeStateAtomic(
97 filePath: string,
98 state: CacheStatsState,
99): Promise<void> {
100 const dir = dirname(filePath)
101 await mkdir(dir, { recursive: true })
102 const tmp = `${filePath}.${process.pid}.tmp`
103 try {
104 await writeFile(tmp, JSON.stringify(state), 'utf8')
105 await rename(tmp, filePath)
106 } catch {
107 // Best-effort; silently ignore errors so the UI never crashes
108 }
109}

Callers 2

onResponseFunction · 0.85
cacheStats.test.tsFile · 0.85

Calls 2

mkdirFunction · 0.85
renameFunction · 0.85

Tested by

no test coverage detected