aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/installation/download_file.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-23 10:02:08 +0000
committerGitHub <[email protected]>2020-02-23 10:02:08 +0000
commit58d44c6ba2de32a31a09bbcaf61365a69b69374c (patch)
tree40f50d70e9ac2bb48d680e4b2fc4a4480eaf4f99 /editors/code/src/installation/download_file.ts
parentdea1d957e5fec51e8210b3fc4d2db7099d0ff000 (diff)
parent49844ab717d8d1790dbdf7f44d160936ece0e80f (diff)
Merge #3261
3261: Extract client-side logging r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
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) => {