show error modal when update failed
This commit is contained in:
parent
73fb9464d2
commit
1de9fce504
6
app.js
6
app.js
|
@ -82,6 +82,12 @@ const run = () => {
|
||||||
type: "update-complete"
|
type: "update-complete"
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
downloadTask.on('error', () => {
|
||||||
|
mainWindow.webContents.send('status_update', {
|
||||||
|
type: "error",
|
||||||
|
message: "An error occured while updating."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
} else
|
} else
|
||||||
mainWindow.webContents.send('status_update', {
|
mainWindow.webContents.send('status_update', {
|
||||||
|
|
|
@ -98,14 +98,14 @@ async function filesThatNeedUpdate(osuPath, updateFiles) {
|
||||||
fileName,
|
fileName,
|
||||||
fileURL
|
fileURL
|
||||||
})
|
})
|
||||||
// console.log("hashes are not matching", `(${existingFileMD5} - ${fileHash})`);
|
//console.log("hashes are not matching", `(${existingFileMD5} - ${fileHash})`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filesToDownload.push({
|
filesToDownload.push({
|
||||||
fileName,
|
fileName,
|
||||||
fileURL
|
fileURL
|
||||||
});
|
});
|
||||||
// console.log("new file " + fileName);
|
//console.log("new file " + fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return filesToDownload;
|
return filesToDownload;
|
||||||
|
@ -116,6 +116,7 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
|
||||||
let completedIndex = 0;
|
let completedIndex = 0;
|
||||||
filesToUpdate.forEach(async (fileToUpdate) => {
|
filesToUpdate.forEach(async (fileToUpdate) => {
|
||||||
const filePath = path.join(osuPath, fileToUpdate.fileName);
|
const filePath = path.join(osuPath, fileToUpdate.fileName);
|
||||||
|
console.log(filePath);
|
||||||
if (await fu.existsAsync(filePath))
|
if (await fu.existsAsync(filePath))
|
||||||
await fs.promises.rm(filePath);
|
await fs.promises.rm(filePath);
|
||||||
|
|
||||||
|
@ -128,6 +129,10 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
|
||||||
if (completedIndex >= filesToUpdate.length)
|
if (completedIndex >= filesToUpdate.length)
|
||||||
eventEmitter.emit('completed');
|
eventEmitter.emit('completed');
|
||||||
});
|
});
|
||||||
|
fileDownload.on('error', (err) => {
|
||||||
|
console.log(err);
|
||||||
|
eventEmitter.emit('error');
|
||||||
|
});
|
||||||
|
|
||||||
fileDownload.start().catch(err => console.error(err));
|
fileDownload.start().catch(err => console.error(err));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user