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)); });