From cfbc7c33326a840fd4b8941d1d5baaab833efd56 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Thu, 9 Mar 2023 16:19:32 +0100 Subject: handle HTTP errors when downloading Northstar In case we get a 404 or similar we should be cancelling the update, as otherwise we'll end up downloading the HTML for a 404 page, and subsequently try to extract that. Clearly not intended or good. --- src/modules/update.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/modules') diff --git a/src/modules/update.js b/src/modules/update.js index 534a5af..e57faf6 100644 --- a/src/modules/update.js +++ b/src/modules/update.js @@ -179,15 +179,22 @@ update.northstar = async () => { if (ns_version != "unknown") { console.log(lang("cli.update.current"), ns_version); }; - - console.log(lang("cli.update.downloading") + ":", latest_version); - ipcMain.emit("ns-update-event", "cli.update.downloading"); } exclude_files(); // start the download of the zip - https.get(requests.getLatestNsVersionLink() + "asd", (res) => { + https.get(requests.getLatestNsVersionLink(), (res) => { + // cancel out if zip can't be retrieved and or found + if (res.statusCode !== 200) { + ipcMain.emit("ns-update-event", "cli.update.uptodate.short"); + console.log(lang("cli.update.uptodate"), ns_version); + return false; + } + + console.log(lang("cli.update.downloading") + ":", latest_version); + ipcMain.emit("ns-update-event", "cli.update.downloading"); + let tmp = path.dirname(settings.zip); if (fs.existsSync(tmp)) { -- cgit v1.2.3