aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
authorMatthias Einwag <[email protected]>2020-09-23 16:37:02 +0100
committerMatthias Einwag <[email protected]>2020-09-23 16:37:02 +0100
commitc7f464774901d40483a6edc4f1294e1648dee4d5 (patch)
tree11b1afe2df88b9909db0155bb384ae4ef486ac4c /editors/code/src/main.ts
parentdf4d59512e496ff010c8710e8ea8e2db4a7f4822 (diff)
Move unlink on download into download function
Since this is required by all callsites its easier to have it in the function itself.
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts14
1 files changed, 3 insertions, 11 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index f865639a1..2896d90ac 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -200,15 +200,11 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
200 const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix"); 200 const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix");
201 201
202 await downloadWithRetryDialog(state, async () => { 202 await downloadWithRetryDialog(state, async () => {
203 // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error.
204 await fs.unlink(dest).catch(err => {
205 if (err.code !== "ENOENT") throw err;
206 });
207
208 await download({ 203 await download({
209 url: artifact.browser_download_url, 204 url: artifact.browser_download_url,
210 dest, 205 dest,
211 progressTitle: "Downloading rust-analyzer extension", 206 progressTitle: "Downloading rust-analyzer extension",
207 overwrite: true,
212 }); 208 });
213 }); 209 });
214 210
@@ -330,17 +326,13 @@ async function getServer(config: Config, state: PersistentState): Promise<string
330 assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); 326 assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
331 327
332 await downloadWithRetryDialog(state, async () => { 328 await downloadWithRetryDialog(state, async () => {
333 // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error.
334 await fs.unlink(dest).catch(err => {
335 if (err.code !== "ENOENT") throw err;
336 });
337
338 await download({ 329 await download({
339 url: artifact.browser_download_url, 330 url: artifact.browser_download_url,
340 dest, 331 dest,
341 progressTitle: "Downloading rust-analyzer server", 332 progressTitle: "Downloading rust-analyzer server",
342 gunzip: true, 333 gunzip: true,
343 mode: 0o755 334 mode: 0o755,
335 overwrite: true,
344 }); 336 });
345 }); 337 });
346 338