guardar en .downloading cuando todavía no se bajó
This commit is contained in:
parent
8cd396335a
commit
e349bc7cad
1 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue