MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / pushDirAsTar

Function pushDirAsTar

e2e/src/vm/desktop.ts:68–86  ·  view source on GitHub ↗
(
  ip: string,
  localDir: string,
  remoteParent: string,
)

Source from the content-addressed store, hash-verified

66 * lands at `${remoteParent}/${basename(localDir)}`.
67 */
68export const pushDirAsTar = async (
69 ip: string,
70 localDir: string,
71 remoteParent: string,
72): Promise<void> => {
73 const parent = dirname(localDir);
74 const base = basename(localDir);
75 const remote = `${SSHPASS} -p ${GUEST_PASS} ssh ${SSH_OPTS.join(" ")} ${GUEST_USER}@${ip} ${JSON.stringify(
76 `mkdir -p ${remoteParent} && tar xf - -C ${remoteParent}`,
77 )}`;
78 const pipeline = `tar cf - -C ${JSON.stringify(parent)} ${JSON.stringify(base)} | ${remote}`;
79 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: one retry over a flaky just-booted guest link
80 try {
81 await execFileP("sh", ["-c", pipeline], { maxBuffer: 16 * 1024 * 1024 });
82 } catch {
83 await sleep(3000);
84 await execFileP("sh", ["-c", pipeline], { maxBuffer: 16 * 1024 * 1024 });
85 }
86};
87
88const freePort = (): Promise<number> =>
89 new Promise((resolve, reject) => {

Callers 2

provisionMacFunction · 0.90
provisionLinuxFunction · 0.90

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected