Files
orca/src/main/macos-tree-clone.ts
T
OrcaWinandOrcaWin 89e93cfa38 [comment audit] Shorten top-level main process L–O comments (#32295)
* chore: shorten process-host comments

* chore: audit CLI parsing and host-routing comments

* chore: remove stale host-selector restriction comment

* chore: shorten remaining CLI root comments

* Shorten CLI handler comments

* Shorten CLI runtime and command specification comments

* Shorten top-level main process A–G comments

* [comment audit] Shorten main process H–K comments

* [comment audit] Shorten main process L–O comments

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-23 11:06:55 -07:00

28 lines
929 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { basename } from 'node:path'
import { runProcess } from '@orca/process-host'
import { rm } from './asar-transparent-fs'
/** Requires an existing destination parent; whole-tree cp avoids Node’s file-by-file APFS overhead. */
export async function cloneMacTree(
source: string,
destination: string,
signal?: AbortSignal
): Promise<void> {
// Clear partial clones before fallback, and prevent cp -R from nesting into an existing destination.
for (const flags of ['-cR', '-R']) {
await rm(destination, { recursive: true, force: true })
// Large trees copied at background I/O priority can exceed the default timeout.
const result = await runProcess({
program: '/bin/cp',
args: [flags, source, destination],
timeoutMs: null,
maxOutputBytes: 8192,
signal
})
if (result.code === 0) {
return
}
}
throw new Error(`Could not copy ${basename(source)}`)
}