From 1de9fce50474a10449f56ed243c6c1fb8f13d021 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Thu, 20 Oct 2022 19:08:48 +0200 Subject: [PATCH] show error modal when update failed --- app.js | 6 ++++++ osuUtil.js | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 72b344c..498aa81 100644 --- a/app.js +++ b/app.js @@ -82,6 +82,12 @@ const run = () => { type: "update-complete" }) }); + downloadTask.on('error', () => { + mainWindow.webContents.send('status_update', { + type: "error", + message: "An error occured while updating." + }); + }); } else mainWindow.webContents.send('status_update', { diff --git a/osuUtil.js b/osuUtil.js index 5122c06..b67c7c6 100644 --- a/osuUtil.js +++ b/osuUtil.js @@ -98,14 +98,14 @@ async function filesThatNeedUpdate(osuPath, updateFiles) { fileName, fileURL }) - // console.log("hashes are not matching", `(${existingFileMD5} - ${fileHash})`); + //console.log("hashes are not matching", `(${existingFileMD5} - ${fileHash})`); } } else { filesToDownload.push({ fileName, fileURL }); - // console.log("new file " + fileName); + //console.log("new file " + fileName); } } return filesToDownload; @@ -116,6 +116,7 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) { let completedIndex = 0; filesToUpdate.forEach(async (fileToUpdate) => { const filePath = path.join(osuPath, fileToUpdate.fileName); + console.log(filePath); if (await fu.existsAsync(filePath)) await fs.promises.rm(filePath); @@ -128,6 +129,10 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) { if (completedIndex >= filesToUpdate.length) eventEmitter.emit('completed'); }); + fileDownload.on('error', (err) => { + console.log(err); + eventEmitter.emit('error'); + }); fileDownload.start().catch(err => console.error(err)); });