MCPcopy Create free account
hub / github.com/Kevin7Qi/codex-collab / writeThreadsFileAt

Function writeThreadsFileAt

src/threads.ts:104–110  ·  view source on GitHub ↗

Atomic write of a threads file at an explicit path. Used by saveThreadIndex * and by legacy-global-file maintenance in the migration code below.

(filePath: string, index: ThreadIndex)

Source from the content-addressed store, hash-verified

102/** Atomic write of a threads file at an explicit path. Used by saveThreadIndex
103 * and by legacy-global-file maintenance in the migration code below. */
104function writeThreadsFileAt(filePath: string, index: ThreadIndex): void {
105 const dir = dirname(filePath);
106 if (!existsSync(dir)) mkdirSync(dir, { recursive: true, mode: 0o700 });
107 const tmpPath = filePath + ".tmp";
108 writeFileSync(tmpPath, JSON.stringify(index, null, 2), { mode: 0o600 });
109 renameSync(tmpPath, filePath);
110}
111
112export function saveThreadIndex(stateDir: string, index: ThreadIndex): void {
113 writeThreadsFileAt(threadsFilePath(stateDir), index);

Callers 2

saveThreadIndexFunction · 0.85
removeLegacyGlobalThreadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected