MCPcopy Create free account
hub / github.com/anomalyco/opencode / exclusiveWrite

Function exclusiveWrite

packages/core/src/util/effect-flock.ts:128–136  ·  view source on GitHub ↗
(filePath: string, content: string, lockDir: string, detail: string)

Source from the content-addressed store, hash-verified

126
127 /** Write with exclusive create — compromised error if file already exists. */
128 const exclusiveWrite = (filePath: string, content: string, lockDir: string, detail: string) =>
129 fs.writeFileString(filePath, content, { flag: "wx" }).pipe(
130 Effect.catch(() =>
131 Effect.gen(function* () {
132 yield* forceRemove(lockDir)
133 return yield* new LockCompromisedError({ detail })
134 }),
135 ),
136 )
137
138 const cleanStaleBreaker = Effect.fnUntraced(function* (breakerPath: string) {
139 const bs = yield* safeStat(breakerPath)

Callers 1

tryAcquireLockDirFunction · 0.85

Calls 1

forceRemoveFunction · 0.85

Tested by

no test coverage detected