Decouple http file stream logic from temp dir logic

This commit is contained in:
Veetaha 2020-06-22 21:36:56 +03:00
parent ceb69203b5
commit 0514d817db
2 changed files with 57 additions and 44 deletions

View file

@ -178,7 +178,11 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix");
await download(artifact.browser_download_url, dest, "Downloading rust-analyzer extension");
await download({
url: artifact.browser_download_url,
dest,
progressTitle: "Downloading rust-analyzer extension",
});
await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest));
await fs.unlink(dest);
@ -299,7 +303,12 @@ async function getServer(config: Config, state: PersistentState): Promise<string
if (err.code !== "ENOENT") throw err;
});
await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 });
await download({
url: artifact.browser_download_url,
dest,
progressTitle: "Downloading rust-analyzer server",
mode: 0o755
});
// Patching executable if that's NixOS.
if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) {