MCPcopy Index your code
hub / github.com/codeaashu/claude-code / atomicMoveToInstallPath

Function atomicMoveToInstallPath

src/utils/nativeInstaller/installer.ts:300–326  ·  view source on GitHub ↗
(
  stagedBinaryPath: string,
  installPath: string,
)

Source from the content-addressed store, hash-verified

298}
299
300async function atomicMoveToInstallPath(
301 stagedBinaryPath: string,
302 installPath: string,
303) {
304 // Create installation directory if it doesn't exist
305 await mkdir(dirname(installPath), { recursive: true })
306
307 // Move from staging to final location atomically
308 const tempInstallPath = `${installPath}.tmp.${process.pid}.${Date.now()}`
309
310 try {
311 // Copy to temp next to install path, then rename. A direct rename from staging
312 // would fail with EXDEV if staging and install are on different filesystems.
313 await copyFile(stagedBinaryPath, tempInstallPath)
314 await chmod(tempInstallPath, 0o755)
315 await rename(tempInstallPath, installPath)
316 logForDebugging(`Atomically installed binary to ${installPath}`)
317 } catch (error) {
318 // Clean up temp file if it exists
319 try {
320 await unlink(tempInstallPath)
321 } catch {
322 // Ignore cleanup errors
323 }
324 throw error
325 }
326}
327
328async function installVersionFromPackage(
329 stagingPath: string,

Callers 2

installVersionFromBinaryFunction · 0.85

Calls 4

mkdirFunction · 0.85
renameFunction · 0.85
logForDebuggingFunction · 0.85
unlinkFunction · 0.85

Tested by

no test coverage detected