File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -200,15 +200,11 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
200
200
const dest = path . join ( config . globalStoragePath , "rust-analyzer.vsix" ) ;
201
201
202
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
203
await download ( {
209
204
url : artifact . browser_download_url ,
210
205
dest,
211
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
326
assert ( ! ! artifact , `Bad release: ${ JSON . stringify ( release ) } ` ) ;
331
327
332
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
329
await download ( {
339
330
url : artifact . browser_download_url ,
340
331
dest,
341
332
progressTitle : "Downloading rust-analyzer server" ,
342
333
gunzip : true ,
343
- mode : 0o755
334
+ mode : 0o755 ,
335
+ overwrite : true ,
344
336
} ) ;
345
337
} ) ;
346
338
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ interface DownloadOpts {
76
76
dest : string ;
77
77
mode ?: number ;
78
78
gunzip ?: boolean ;
79
+ overwrite ?: boolean ,
79
80
}
80
81
81
82
export async function download ( opts : DownloadOpts ) {
@@ -85,6 +86,13 @@ export async function download(opts: DownloadOpts) {
85
86
const randomHex = crypto . randomBytes ( 5 ) . toString ( "hex" ) ;
86
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
96
await vscode . window . withProgress (
89
97
{
90
98
location : vscode . ProgressLocation . Notification ,
You can’t perform that action at this time.
0 commit comments