MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / atomicWrite

Function atomicWrite

packages/migration-legacy/src/atomic-write.ts:10–19  ·  view source on GitHub ↗
(path: string, data: string)

Source from the content-addressed store, hash-verified

8 * write that overwrites an existing user-owned file.
9 */
10export async function atomicWrite(path: string, data: string): Promise<void> {
11 const tmp = `${path}.${process.pid}.tmp`;
12 // Migrated config/MCP files can carry provider API keys. Create them
13 // private (0600) so they are never group/world-readable, even when the
14 // target home directory itself has permissive permissions. `chmod` covers
15 // the case where a stale temp file from a crashed run already exists.
16 await writeFile(tmp, data, { encoding: 'utf-8', mode: 0o600 });
17 await chmod(tmp, 0o600);
18 await rename(tmp, path);
19}

Callers 4

writeReportFunction · 0.70
migrateMcpStepFunction · 0.50
migrateConfigStepFunction · 0.50

Calls 1

writeFileFunction · 0.50

Tested by

no test coverage detected