MCPcopy
hub / github.com/garrytan/gstack / writeStateFile

Function writeStateFile

design/src/daemon-state.ts:97–105  ·  view source on GitHub ↗
(
  state: DaemonState,
  stateFile: string = resolveStateFilePath(),
)

Source from the content-addressed store, hash-verified

95}
96
97export function writeStateFile(
98 state: DaemonState,
99 stateFile: string = resolveStateFilePath(),
100): void {
101 fs.mkdirSync(path.dirname(stateFile), { recursive: true });
102 const tmp = `${stateFile}.tmp.${process.pid}.${Math.random().toString(36).slice(2)}`;
103 fs.writeFileSync(tmp, JSON.stringify(state, null, 2), { mode: 0o600 });
104 fs.renameSync(tmp, stateFile);
105}
106
107export function removeStateFile(stateFile: string = resolveStateFilePath()): void {
108 try {

Callers 1

startFunction · 0.90

Calls 1

resolveStateFilePathFunction · 0.85

Tested by

no test coverage detected