(runId, request, suffix, protocol)
| 267 | if (typeof bytes !== "string" || !bytes) throw new Error("snapshot bytes are required"); |
| 268 | const data = Buffer.from(bytes, "base64"); |
| 269 | if (!data.length || data.byteLength > 100 * 1024 * 1024) throw new Error("snapshot is empty or too large"); |
| 270 | const root = await mkdtemp(join(tmpdir(), "cloudbox-")); |
| 271 | const archive = join(root, "snapshot.tar.gz"); |
| 272 | await writeFile(archive, data); |
| 273 | const receipt = await run(`tar -xzf ${shell(archive)} -C ${shell(root)}`, root); |
| 274 | await rm(archive, { force: true }); |
| 275 | if (receipt.code !== 0) { |
| 276 | await rm(root, { recursive: true, force: true }); |
| 277 | return { ok: false, runId, error: receipt.stderr || receipt.stdout, receipt }; |
| 278 | } |
| 279 | liveRuns.set(runId, { root, workspace: join(root, "repo"), createdAt: new Date().toISOString() }); |
| 280 | return { ok: true, runId }; |
| 281 | } |
| 282 | |
| 283 | async function handleLiveDelete(runId) { |
| 284 | safeRunId(runId); |
no test coverage detected