diff options
Diffstat (limited to 'editors/code/src/net.ts')
-rw-r--r-- | editors/code/src/net.ts | 8 |
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 | ||
81 | export async function download(opts: DownloadOpts) { | 82 | export 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, |