From e349bc7cadf0ce967b72ed8e56ae766e39eb2fec Mon Sep 17 00:00:00 2001 From: Nulo Date: Mon, 17 Jul 2023 19:48:21 -0300 Subject: [PATCH] =?UTF-8?q?guardar=20en=20.downloading=20cuando=20todav?= =?UTF-8?q?=C3=ADa=20no=20se=20baj=C3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/container-baby.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/container-baby.ts b/server/container-baby.ts index 24e30c9..67f286c 100644 --- a/server/container-baby.ts +++ b/server/container-baby.ts @@ -1,5 +1,5 @@ import { execFile as _execFile } from "node:child_process"; -import { access, mkdir, open, writeFile } from "node:fs/promises"; +import { access, mkdir, open, rename, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { tar2squashfs } from "./tar2squashfs.js"; import { subtle } from "node:crypto"; @@ -76,6 +76,7 @@ async function saveSquashfs( if (!p) { p = (async () => { const output = join(cacheDir, key); + const progressFile = output + ".downloading"; try { await access(output); // ya está cacheado @@ -92,7 +93,7 @@ async function saveSquashfs( const res = await getBlob(image, layer.digest); return res.body!; }); - await tar2squashfs(layerStreams, output, [ + await tar2squashfs(layerStreams, progressFile, [ { content: configJson, headers: { @@ -103,6 +104,7 @@ async function saveSquashfs( }, }, ]); + await rename(progressFile, output); } return output; })();