MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / writeLockFile

Function writeLockFile

source code/utils/nativeInstaller/pidLock.ts:212–234  ·  view source on GitHub ↗

* Write lock content to a file atomically

(
  lockFilePath: string,
  content: VersionLockContent,
)

Source from the content-addressed store, hash-verified

210 * Write lock content to a file atomically
211 */
212function writeLockFile(
213 lockFilePath: string,
214 content: VersionLockContent,
215): void {
216 const fs = getFsImplementation()
217 const tempPath = `${lockFilePath}.tmp.${process.pid}.${Date.now()}`
218
219 try {
220 writeFileSync_DEPRECATED(tempPath, jsonStringify(content, null, 2), {
221 encoding: 'utf8',
222 flush: true,
223 })
224 fs.renameSync(tempPath, lockFilePath)
225 } catch (error) {
226 // Clean up temp file on failure (best-effort)
227 try {
228 fs.unlinkSync(tempPath)
229 } catch {
230 // Ignore cleanup errors (ENOENT expected if write failed before file creation)
231 }
232 throw error
233 }
234}
235
236/**
237 * Try to acquire a lock on a version file

Callers 1

tryAcquireLockFunction · 0.85

Calls 3

getFsImplementationFunction · 0.85
writeFileSync_DEPRECATEDFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected