diff options
author | 0neGal <mail@0negal.com> | 2023-03-09 16:19:32 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-03-09 16:20:35 +0100 |
commit | cfbc7c33326a840fd4b8941d1d5baaab833efd56 (patch) | |
tree | d0ad205ed6f18133c63461383912f4a5605cdcea /src/modules | |
parent | d59cbd05f3d238b69458df458b58b67b439f0590 (diff) | |
download | Viper-cfbc7c33326a840fd4b8941d1d5baaab833efd56.tar.gz Viper-cfbc7c33326a840fd4b8941d1d5baaab833efd56.zip |
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.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/update.js | 15 |
1 files changed, 11 insertions, 4 deletions
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)) { |