diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/main.ts | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 9743115fb..409e4b5c2 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -194,11 +194,19 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi | |||
194 | assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); | 194 | assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); |
195 | 195 | ||
196 | const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix"); | 196 | const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix"); |
197 | await download({ | 197 | |
198 | url: artifact.browser_download_url, | 198 | await performDownloadWithRetryDialog(async () => { |
199 | dest, | 199 | // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error. |
200 | progressTitle: "Downloading rust-analyzer extension", | 200 | await fs.unlink(dest).catch(err => { |
201 | }); | 201 | if (err.code !== "ENOENT") throw err; |
202 | }); | ||
203 | |||
204 | await download({ | ||
205 | url: artifact.browser_download_url, | ||
206 | dest, | ||
207 | progressTitle: "Downloading rust-analyzer extension", | ||
208 | }); | ||
209 | }, state); | ||
202 | 210 | ||
203 | await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest)); | 211 | await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest)); |
204 | await fs.unlink(dest); | 212 | await fs.unlink(dest); |
@@ -317,18 +325,20 @@ async function getServer(config: Config, state: PersistentState): Promise<string | |||
317 | const artifact = release.assets.find(artifact => artifact.name === `rust-analyzer-${platform}.gz`); | 325 | const artifact = release.assets.find(artifact => artifact.name === `rust-analyzer-${platform}.gz`); |
318 | assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); | 326 | assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); |
319 | 327 | ||
320 | // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error. | 328 | await performDownloadWithRetryDialog(async () => { |
321 | await fs.unlink(dest).catch(err => { | 329 | // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error. |
322 | if (err.code !== "ENOENT") throw err; | 330 | await fs.unlink(dest).catch(err => { |
323 | }); | 331 | if (err.code !== "ENOENT") throw err; |
324 | 332 | }); | |
325 | await download({ | 333 | |
326 | url: artifact.browser_download_url, | 334 | await download({ |
327 | dest, | 335 | url: artifact.browser_download_url, |
328 | progressTitle: "Downloading rust-analyzer server", | 336 | dest, |
329 | gunzip: true, | 337 | progressTitle: "Downloading rust-analyzer server", |
330 | mode: 0o755 | 338 | gunzip: true, |
331 | }); | 339 | mode: 0o755 |
340 | }); | ||
341 | }, state); | ||
332 | 342 | ||
333 | // Patching executable if that's NixOS. | 343 | // Patching executable if that's NixOS. |
334 | if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) { | 344 | if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) { |
@@ -372,10 +382,10 @@ async function queryForGithubToken(state: PersistentState): Promise<void> { | |||
372 | password: true, | 382 | password: true, |
373 | prompt: ` | 383 | prompt: ` |
374 | This dialog allows to store a Github authorization token. | 384 | This dialog allows to store a Github authorization token. |
375 | The usage of an authorization token allows will increase the rate | 385 | The usage of an authorization token will increase the rate |
376 | limit on the use of Github APIs and can thereby prevent getting | 386 | limit on the use of Github APIs and can thereby prevent getting |
377 | throttled. | 387 | throttled. |
378 | Auth tokens can be obtained at https://github.com/settings/tokens`, | 388 | Auth tokens can be created at https://github.com/settings/tokens`, |
379 | }; | 389 | }; |
380 | 390 | ||
381 | const newToken = await vscode.window.showInputBox(githubTokenOptions); | 391 | const newToken = await vscode.window.showInputBox(githubTokenOptions); |
@@ -383,4 +393,4 @@ async function queryForGithubToken(state: PersistentState): Promise<void> { | |||
383 | log.info("Storing new github token"); | 393 | log.info("Storing new github token"); |
384 | await state.updateGithubToken(newToken); | 394 | await state.updateGithubToken(newToken); |
385 | } | 395 | } |
386 | } \ No newline at end of file | 396 | } |