aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/installation/download_file.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/installation/download_file.ts')
-rw-r--r--editors/code/src/installation/download_file.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts
index d154f4816..319cb995c 100644
--- a/editors/code/src/installation/download_file.ts
+++ b/editors/code/src/installation/download_file.ts
@@ -3,6 +3,7 @@ import * as fs from "fs";
3import * as stream from "stream"; 3import * as stream from "stream";
4import * as util from "util"; 4import * as util from "util";
5import { strict as assert } from "assert"; 5import { strict as assert } from "assert";
6import { log } from "../util";
6 7
7const pipeline = util.promisify(stream.pipeline); 8const pipeline = util.promisify(stream.pipeline);
8 9
@@ -21,8 +22,8 @@ export async function downloadFile(
21 const res = await fetch(url); 22 const res = await fetch(url);
22 23
23 if (!res.ok) { 24 if (!res.ok) {
24 console.log("Error", res.status, "while downloading file from", url); 25 log.error("Error", res.status, "while downloading file from", url);
25 console.dir({ body: await res.text(), headers: res.headers }, { depth: 3 }); 26 log.error({ body: await res.text(), headers: res.headers });
26 27
27 throw new Error(`Got response ${res.status} when trying to download a file.`); 28 throw new Error(`Got response ${res.status} when trying to download a file.`);
28 } 29 }
@@ -30,7 +31,7 @@ export async function downloadFile(
30 const totalBytes = Number(res.headers.get('content-length')); 31 const totalBytes = Number(res.headers.get('content-length'));
31 assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); 32 assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol");
32 33
33 console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath); 34 log.debug("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath);
34 35
35 let readBytes = 0; 36 let readBytes = 0;
36 res.body.on("data", (chunk: Buffer) => { 37 res.body.on("data", (chunk: Buffer) => {