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.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts
index 8a0766c66..f1f9f4a25 100644
--- a/editors/code/src/installation/download_file.ts
+++ b/editors/code/src/installation/download_file.ts
@@ -3,7 +3,7 @@ import * as fs from "fs";
3import { strict as assert } from "assert"; 3import { strict as assert } from "assert";
4 4
5/** 5/**
6 * Downloads file from `url` and stores it at `destFilePath`. 6 * Downloads file from `url` and stores it at `destFilePath` with `destFilePermissions`.
7 * `onProgress` callback is called on recieveing each chunk of bytes 7 * `onProgress` callback is called on recieveing each chunk of bytes
8 * to track the progress of downloading, it gets the already read and total 8 * to track the progress of downloading, it gets the already read and total
9 * amount of bytes to read as its parameters. 9 * amount of bytes to read as its parameters.
@@ -11,6 +11,7 @@ import { strict as assert } from "assert";
11export async function downloadFile( 11export async function downloadFile(
12 url: string, 12 url: string,
13 destFilePath: fs.PathLike, 13 destFilePath: fs.PathLike,
14 destFilePermissions: number,
14 onProgress: (readBytes: number, totalBytes: number) => void 15 onProgress: (readBytes: number, totalBytes: number) => void
15): Promise<void> { 16): Promise<void> {
16 const res = await fetch(url); 17 const res = await fetch(url);
@@ -35,6 +36,9 @@ export async function downloadFile(
35 onProgress(readBytes, totalBytes); 36 onProgress(readBytes, totalBytes);
36 }) 37 })
37 .on("error", reject) 38 .on("error", reject)
38 .pipe(fs.createWriteStream(destFilePath).on("close", resolve)) 39 .pipe(fs
40 .createWriteStream(destFilePath, { mode: destFilePermissions })
41 .on("close", resolve)
42 )
39 ); 43 );
40} 44}