From b9bd87c0994121f2cb2e8af66275db749bb75fa4 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 22 Jan 2024 12:06:04 +0100 Subject: [PATCH] remove old files before replacing them --- electron/osuUtil.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/electron/osuUtil.js b/electron/osuUtil.js index a3112e3..bf62e1f 100644 --- a/electron/osuUtil.js +++ b/electron/osuUtil.js @@ -224,6 +224,11 @@ function downloadUpdateFiles(osuPath, updateFiles) { }); }); try { + if (fs.existsSync(path.join(osuPath, fileName))) { + await fs.promises.rm(path.join(osuPath, fileName), { + force: true, + }); + } await fs.promises.writeFile( path.join(osuPath, fileName), axiosDownloadWithProgress.data, @@ -298,6 +303,11 @@ function downloadPatcherUpdates(osuPath, patcherUpdates) { }); try { + if (fs.existsSync(path.join(osuPath, "EZPPLauncher", fileName))) { + await fs.promises.rm(path.join(osuPath, "EZPPLauncher", fileName), { + force: true, + }); + } await fs.promises.writeFile( path.join(osuPath, "EZPPLauncher", fileName), axiosDownloadWithProgress.data, @@ -362,6 +372,12 @@ function downloadUIFiles(osuPath, uiFiles) { }, }); try { + if (fs.existsSync(path.join(osuPath, "EZPPLauncher", fileName))) { + await fs.promises.rm(path.join(osuPath, "EZPPLauncher", fileName), { + force: true, + }); + } + await fs.promises.writeFile( path.join(osuPath, "EZPPLauncher", fileName), axiosDownloadWithProgress.data,