From b834b376826a6ff9a24d88894a91b810460960ec Mon Sep 17 00:00:00 2001 From: Veetaha Date: Tue, 11 Feb 2020 22:34:52 +0200 Subject: vscode: remove chmod in favour of an option to createWriteStream() --- editors/code/src/installation/download_file.ts | 8 ++++++-- editors/code/src/installation/language_server.ts | 5 ++--- 2 files changed, 8 insertions(+), 5 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"; import { strict as assert } from "assert"; /** - * Downloads file from `url` and stores it at `destFilePath`. + * Downloads file from `url` and stores it at `destFilePath` with `destFilePermissions`. * `onProgress` callback is called on recieveing each chunk of bytes * to track the progress of downloading, it gets the already read and total * amount of bytes to read as its parameters. @@ -11,6 +11,7 @@ import { strict as assert } from "assert"; export async function downloadFile( url: string, destFilePath: fs.PathLike, + destFilePermissions: number, onProgress: (readBytes: number, totalBytes: number) => void ): Promise { const res = await fetch(url); @@ -35,6 +36,9 @@ export async function downloadFile( onProgress(readBytes, totalBytes); }) .on("error", reject) - .pipe(fs.createWriteStream(destFilePath).on("close", resolve)) + .pipe(fs + .createWriteStream(destFilePath, { mode: destFilePermissions }) + .on("close", resolve) + ) ); } diff --git a/editors/code/src/installation/language_server.ts b/editors/code/src/installation/language_server.ts index 3510f9178..52c5cbe7d 100644 --- a/editors/code/src/installation/language_server.ts +++ b/editors/code/src/installation/language_server.ts @@ -35,7 +35,8 @@ export async function downloadLatestLanguageServer( }, async (progress, _cancellationToken) => { let lastPrecentage = 0; - await downloadFile(downloadUrl, installationPath, throttle( + const filePermissions = 0o755; // (rwx, r_x, r_x) + await downloadFile(downloadUrl, installationPath, filePermissions, throttle( 200, /* noTrailing: */ true, (readBytes, totalBytes) => { @@ -51,8 +52,6 @@ export async function downloadLatestLanguageServer( } ); console.timeEnd("Downloading ra_lsp_server"); - - await fs.chmod(installationPath, 0o755); // Set (rwx, r_x, r_x) permissions } export async function ensureLanguageServerBinary( langServerSource: null | BinarySource -- cgit v1.2.3