mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
vscode: added logging when donloading binaries
This commit is contained in:
parent
f3240e22c6
commit
7cba77ed4e
3 changed files with 26 additions and 5 deletions
|
@ -20,6 +20,8 @@ export async function downloadFile(
|
||||||
|
|
||||||
let readBytes = 0;
|
let readBytes = 0;
|
||||||
|
|
||||||
|
console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath);
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) => response.body
|
return new Promise<void>((resolve, reject) => response.body
|
||||||
.on("data", (chunk: Buffer) => {
|
.on("data", (chunk: Buffer) => {
|
||||||
readBytes += chunk.length;
|
readBytes += chunk.length;
|
||||||
|
|
|
@ -19,6 +19,8 @@ export async function fetchLatestArtifactMetadata(
|
||||||
|
|
||||||
// We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`)
|
// We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`)
|
||||||
|
|
||||||
|
console.log("Issuing request for released artifacts metadata to", requestUrl);
|
||||||
|
|
||||||
const response: GithubRelease = await fetch(requestUrl, {
|
const response: GithubRelease = await fetch(requestUrl, {
|
||||||
headers: { Accept: "application/vnd.github.v3+json" }
|
headers: { Accept: "application/vnd.github.v3+json" }
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,6 +2,7 @@ import * as vscode from "vscode";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { strict as assert } from "assert";
|
import { strict as assert } from "assert";
|
||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "fs";
|
||||||
|
import { promises as dns } from "dns";
|
||||||
import { spawnSync } from "child_process";
|
import { spawnSync } from "child_process";
|
||||||
import { throttle } from "throttle-debounce";
|
import { throttle } from "throttle-debounce";
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ export async function downloadLatestLanguageServer(
|
||||||
|
|
||||||
const installationPath = path.join(installationDir, artifactFileName);
|
const installationPath = path.join(installationDir, artifactFileName);
|
||||||
|
|
||||||
|
console.time("Downloading ra_lsp_server");
|
||||||
await vscode.window.withProgress(
|
await vscode.window.withProgress(
|
||||||
{
|
{
|
||||||
location: vscode.ProgressLocation.Notification,
|
location: vscode.ProgressLocation.Notification,
|
||||||
|
@ -48,6 +50,7 @@ export async function downloadLatestLanguageServer(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
console.timeEnd("Downloading ra_lsp_server");
|
||||||
|
|
||||||
await fs.chmod(installationPath, 0o755); // Set (rwx, r_x, r_x) permissions
|
await fs.chmod(installationPath, 0o755); // Set (rwx, r_x, r_x) permissions
|
||||||
}
|
}
|
||||||
|
@ -101,15 +104,21 @@ export async function ensureLanguageServerBinary(
|
||||||
`Failed to download language server from ${langServerSource.repo.name} ` +
|
`Failed to download language server from ${langServerSource.repo.name} ` +
|
||||||
`GitHub repository: ${err.message}`
|
`GitHub repository: ${err.message}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await dns.resolve('www.google.com').catch(err => {
|
||||||
|
console.error("DNS resolution failed, there might be an issue with Internet availability");
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isBinaryAvailable(prebuiltBinaryPath)) assert(false,
|
||||||
assert(
|
`Downloaded language server binary is not functional.` +
|
||||||
isBinaryAvailable(prebuiltBinaryPath),
|
`Downloaded from: ${JSON.stringify(langServerSource)}`
|
||||||
"Downloaded language server binary is not functional"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
vscode.window.showInformationMessage(
|
vscode.window.showInformationMessage(
|
||||||
"Rust analyzer language server was successfully installed 🦀"
|
"Rust analyzer language server was successfully installed 🦀"
|
||||||
);
|
);
|
||||||
|
@ -119,6 +128,14 @@ export async function ensureLanguageServerBinary(
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBinaryAvailable(binaryPath: string) {
|
function isBinaryAvailable(binaryPath: string) {
|
||||||
return spawnSync(binaryPath, ["--version"]).status === 0;
|
const res = spawnSync(binaryPath, ["--version"]);
|
||||||
|
|
||||||
|
// ACHTUNG! `res` type declaration is inherently wrong, see
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/42221
|
||||||
|
|
||||||
|
console.log("Checked binary availablity via --version", res);
|
||||||
|
console.log(binaryPath, "--version output:", res.output?.map(String));
|
||||||
|
|
||||||
|
return res.status === 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue