From f6cb7a1c3eda6bdbcce3fbd89e8d019e87c4a7a4 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 24 Aug 2023 11:41:37 -0700 Subject: fix unlink --- extension/src/activation/environmentSetup.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'extension/src/activation/environmentSetup.ts') diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 4394eb59..23c0d7de 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -103,7 +103,9 @@ async function checkOrKillRunningServer(serverUrl: string): Promise { console.log("Failed to kill old server:", e); } } - fs.unlinkSync(serverVersionPath()); + if (fs.existsSync(serverVersionPath())) { + fs.unlinkSync(serverVersionPath()); + } // Also delete the server binary const serverBinaryPath = path.join( getExtensionUri().fsPath, @@ -148,7 +150,9 @@ export async function downloadFromS3( }); download.on("error", (err: any) => { - fs.unlink(destination, () => {}); + if (fs.existsSync(destination)) { + fs.unlink(destination, () => {}); + } throw err; }); @@ -205,11 +209,15 @@ export async function startContinuePythonServer(redownload: boolean = true) { shouldDownload = false; } else { console.log("Old version of the server downloaded"); - fs.unlinkSync(destination); + if (fs.existsSync(destination)) { + fs.unlinkSync(destination); + } } } else { console.log("Old version of the server downloaded"); - fs.unlinkSync(destination); + if (fs.existsSync(destination)) { + fs.unlinkSync(destination); + } } } -- cgit v1.2.3-70-g09d2