aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/net.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/net.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/net.ts')
-rw-r--r--editors/code/src/net.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts
index cfbe1fd48..e746465d1 100644
--- a/editors/code/src/net.ts
+++ b/editors/code/src/net.ts
@@ -76,6 +76,7 @@ interface DownloadOpts {
76 dest: string; 76 dest: string;
77 mode?: number; 77 mode?: number;
78 gunzip?: boolean; 78 gunzip?: boolean;
79 overwrite?: boolean,
79} 80}
80 81
81export async function download(opts: DownloadOpts) { 82export async function download(opts: DownloadOpts) {
@@ -85,6 +86,13 @@ export async function download(opts: DownloadOpts) {
85 const randomHex = crypto.randomBytes(5).toString("hex"); 86 const randomHex = crypto.randomBytes(5).toString("hex");
86 const tempFile = path.join(dest.dir, `${dest.name}${randomHex}`); 87 const tempFile = path.join(dest.dir, `${dest.name}${randomHex}`);
87 88
89 if (opts.overwrite) {
90 // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error.
91 await fs.promises.unlink(opts.dest).catch(err => {
92 if (err.code !== "ENOENT") throw err;
93 });
94 }
95
88 await vscode.window.withProgress( 96 await vscode.window.withProgress(
89 { 97 {
90 location: vscode.ProgressLocation.Notification, 98 location: vscode.ProgressLocation.Notification,