Skip to content

Commit af5042b

Browse files
bors[bot]Veetaha
and
Veetaha
authored
Merge #3115
3115: vscode: remove chmod in favour of an option to createWriteStream() r=matklad a=Veetaha Inspired by [cpptools code](https://github.com/microsoft/vscode-cpptools/blob/0d91db0e060b946939ee620130c1dbc0fb1d7c42/Extension/src/packageManager.ts#L385-L386) Co-authored-by: Veetaha <[email protected]>
2 parents 6f685df + b834b37 commit af5042b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

editors/code/src/installation/download_file.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import * as fs from "fs";
33
import { strict as assert } from "assert";
44

55
/**
6-
* Downloads file from `url` and stores it at `destFilePath`.
6+
* Downloads file from `url` and stores it at `destFilePath` with `destFilePermissions`.
77
* `onProgress` callback is called on recieveing each chunk of bytes
88
* to track the progress of downloading, it gets the already read and total
99
* amount of bytes to read as its parameters.
1010
*/
1111
export async function downloadFile(
1212
url: string,
1313
destFilePath: fs.PathLike,
14+
destFilePermissions: number,
1415
onProgress: (readBytes: number, totalBytes: number) => void
1516
): Promise<void> {
1617
const res = await fetch(url);
@@ -35,6 +36,9 @@ export async function downloadFile(
3536
onProgress(readBytes, totalBytes);
3637
})
3738
.on("error", reject)
38-
.pipe(fs.createWriteStream(destFilePath).on("close", resolve))
39+
.pipe(fs
40+
.createWriteStream(destFilePath, { mode: destFilePermissions })
41+
.on("close", resolve)
42+
)
3943
);
4044
}

editors/code/src/installation/language_server.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export async function downloadLatestLanguageServer(
3535
},
3636
async (progress, _cancellationToken) => {
3737
let lastPrecentage = 0;
38-
await downloadFile(downloadUrl, installationPath, throttle(
38+
const filePermissions = 0o755; // (rwx, r_x, r_x)
39+
await downloadFile(downloadUrl, installationPath, filePermissions, throttle(
3940
200,
4041
/* noTrailing: */ true,
4142
(readBytes, totalBytes) => {
@@ -51,8 +52,6 @@ export async function downloadLatestLanguageServer(
5152
}
5253
);
5354
console.timeEnd("Downloading ra_lsp_server");
54-
55-
await fs.chmod(installationPath, 0o755); // Set (rwx, r_x, r_x) permissions
5655
}
5756
export async function ensureLanguageServerBinary(
5857
langServerSource: null | BinarySource

0 commit comments

Comments
 (0)