mirror of
https://github.com/catdevnull/transicion-desordenada-diablo
synced 2024-11-29 12:36:19 +00:00
WIP: usar writeStream para guardar archivos
This commit is contained in:
parent
eb18951686
commit
6bd70eaa61
1 changed files with 2 additions and 1 deletions
|
@ -9,6 +9,7 @@ import {
|
||||||
customRequestWithLimitsAndRetries,
|
customRequestWithLimitsAndRetries,
|
||||||
} from "./network.js";
|
} from "./network.js";
|
||||||
import { createWriteStream } from "node:fs";
|
import { createWriteStream } from "node:fs";
|
||||||
|
import { pipeline } from "node:stream/promises";
|
||||||
|
|
||||||
let urls = process.argv.slice(2);
|
let urls = process.argv.slice(2);
|
||||||
if (urls.length < 1) {
|
if (urls.length < 1) {
|
||||||
|
@ -144,7 +145,7 @@ async function downloadDistWithRetries({ dist, dataset, url, outputPath }) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!res.body) throw new Error("no body");
|
if (!res.body) throw new Error("no body");
|
||||||
await writeFile(filePath, res.body);
|
await pipeline(res.body, createWriteStream(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @typedef DownloadJob
|
/** @typedef DownloadJob
|
||||||
|
|
Loading…
Reference in a new issue