aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/js/update.js32
-rw-r--r--src/modules/update.js29
2 files changed, 58 insertions, 3 deletions
diff --git a/src/app/js/update.js b/src/app/js/update.js
index 6aa1b6d..d03db02 100644
--- a/src/app/js/update.js
+++ b/src/app/js/update.js
@@ -41,14 +41,16 @@ ipcRenderer.on("ns-update-event", (event, options) => {
.innerText = `(${lang(key)})`;
}
+ let delay, now;
+
switch(key) {
case "cli.update.uptodate_short":
case "cli.update.no_internet":
// initial value
- let delay = 0;
+ delay = 0;
// get current time
- let now = new Date().getTime();
+ now = new Date().getTime();
// check if `update.ns.last_checked` was less than 500ms
// since now, this variable is set when `update.ns()` is
@@ -73,6 +75,32 @@ ipcRenderer.on("ns-update-event", (event, options) => {
}, delay)
break;
+ case "cli.update.failed":
+ // initial value
+ delay = 0;
+
+ // get current time
+ now = new Date().getTime();
+
+ // check if `update.ns.last_checked` was less than 500ms
+ // since now, this variable is set when `update.ns()` is
+ // called
+ if (now - update.ns.last_checked < 500) {
+ // if less than 500ms has passed, set `delay` to the
+ // amount of milliseconds missing until we've hit that
+ // 500ms threshold
+ delay = 500 - (now - update.ns.last_checked);
+ }
+
+ // Request version number
+ // this will also handle the play button label for us
+ ipcRenderer.send("get-version");
+
+ setTimeout(() => {
+ update_btn();
+ set_buttons(true);
+ update.ns.progress(false);
+ }, delay)
default:
update_btn();
diff --git a/src/modules/update.js b/src/modules/update.js
index c001ba8..c792217 100644
--- a/src/modules/update.js
+++ b/src/modules/update.js
@@ -401,9 +401,36 @@ update.northstar = async (force_install) => {
console.ok(lang("cli.update.download_done"));
+ let destination = unzip.Extract({path: settings().gamepath});
+
+ // If we receive multiple errors of the same type we ignore them
+ let received_errors = [];
+ destination.on("error", (err) => {
+ if (received_errors.indexOf(err.code) >= 0)
+ return;
+
+ received_errors.push(err.code);
+ extract.close();
+ update.northstar.updating = false;
+
+ let description = lang("gui.toast.desc.unknown_error") + " (" + err.code + ")";
+
+ if (err.code == "EACCES") {
+ description = lang("gui.toast.desc.permission_denied");
+ }
+
+ win().toast({
+ scheme: "error",
+ title: lang("gui.toast.title.failed"),
+ description: description
+ })
+
+ win().send("ns-update-event", "cli.update.failed");
+ })
+
// extracts the zip, this is the part where we're actually
// installing Northstar.
- extract.pipe(unzip.Extract({path: settings().gamepath}))
+ extract.pipe(destination)
let extracted = 0;
let size = received;