mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Download artifacts into tmp dir
This commit is contained in:
parent
0f7961d557
commit
dceb81856e
2 changed files with 60 additions and 11 deletions
|
@ -42,7 +42,16 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||
|
||||
const config = new Config(context);
|
||||
const state = new PersistentState(context.globalState);
|
||||
const serverPath = await bootstrap(config, state);
|
||||
const serverPath = await bootstrap(config, state).catch(err => {
|
||||
let message = "Failed to bootstrap rust-analyzer.";
|
||||
if (err.code === "EBUSY" || err.code === "ETXTBSY") {
|
||||
message += " Other vscode windows might be using rust-analyzer, " +
|
||||
"you should close them and reload this window to retry.";
|
||||
}
|
||||
message += " Open \"Help > Toggle Developer Tools > Console\" to see the logs";
|
||||
log.error("Bootstrap error", err);
|
||||
throw new Error(message);
|
||||
});
|
||||
|
||||
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
|
||||
if (workspaceFolder === undefined) {
|
||||
|
@ -285,6 +294,11 @@ async function getServer(config: Config, state: PersistentState): Promise<string
|
|||
const artifact = release.assets.find(artifact => artifact.name === binaryName);
|
||||
assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
|
||||
|
||||
// Unlinking the exe file before moving new one on its place should prevent ETXTBSY error.
|
||||
await fs.unlink(dest).catch(err => {
|
||||
if (err.code !== "ENOENT") throw err;
|
||||
});
|
||||
|
||||
await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 });
|
||||
|
||||
// Patching executable if that's NixOS.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue