diff options
author | Veetaha <[email protected]> | 2020-02-11 20:34:52 +0000 |
---|---|---|
committer | Veetaha <[email protected]> | 2020-02-11 20:34:52 +0000 |
commit | b834b376826a6ff9a24d88894a91b810460960ec (patch) | |
tree | 3a2a99caca4322485dfca215c59c3a0870a44fdd /editors/code/src/installation/download_file.ts | |
parent | 00e672a51b0caec9e2bb7004281ce2f57bdbefe5 (diff) |
vscode: remove chmod in favour of an option to createWriteStream()
Diffstat (limited to 'editors/code/src/installation/download_file.ts')
-rw-r--r-- | editors/code/src/installation/download_file.ts | 8 |
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"; | |||
3 | import { strict as assert } from "assert"; | 3 | import { 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"; | |||
11 | export async function downloadFile( | 11 | export 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 | } |