diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app/js/toasts.js | 2 | ||||
-rw-r--r-- | src/app/js/update.js | 32 | ||||
-rw-r--r-- | src/lang/de.json | 3 | ||||
-rw-r--r-- | src/lang/en.json | 1 | ||||
-rw-r--r-- | src/lang/fr.json | 1 | ||||
-rw-r--r-- | src/lang/zh.json | 1 | ||||
-rw-r--r-- | src/modules/gamepath.js | 16 | ||||
-rw-r--r-- | src/modules/update.js | 25 |
8 files changed, 72 insertions, 9 deletions
diff --git a/src/app/js/toasts.js b/src/app/js/toasts.js index 83ddf6a..bd9d03a 100644 --- a/src/app/js/toasts.js +++ b/src/app/js/toasts.js @@ -75,7 +75,7 @@ toasts.dismiss = (id) => { } ipcRenderer.on("toast", (_, properties) => { - Toast(properties); + toasts.show(properties); }) module.exports = toasts; 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/lang/de.json b/src/lang/de.json index 0eb17dc..5a5ab4d 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -43,7 +43,8 @@ "current": "Jetzige Version:", "download_done": "Herunterladen abgeschlossen! Extrahiere...", "downloading": "Wird heruntergeladen...", - "finished": "Installation/Aktualisierung abeschlossen!", + "failed": "Installation/Aktualisierung fehlgeschlagen!", + "finished": "Installation/Aktualisierung abgeschlossen!", "no_internet": "Keine Internetverbindung", "uptodate": "Installation ist bereits auf dem neusten Stand (%s), aktualisieren wird übersprungen.", "uptodate_short": "Auf dem neusten stand" diff --git a/src/lang/en.json b/src/lang/en.json index f968f73..bf147ab 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -28,6 +28,7 @@ "checking": "Checking for updates...", "download_done": "Download done! Extracting...", "finished": "Installation/Update finished!", + "failed": "Installation/Update failed!", "uptodate": "Latest version (%s) is already installed, skipping update.", "uptodate_short": "Up-to-date", "no_internet": "No Internet connection" diff --git a/src/lang/fr.json b/src/lang/fr.json index 492ba76..c98e143 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -43,6 +43,7 @@ "current": "Version actuelle :", "download_done": "Téléchargement terminé ! Extraction des fichiers...", "downloading": "Téléchargement en cours...", + "failed": "Échec de la mise à jour !", "finished": "Mise à jour terminée !", "no_internet": "Pas de connexion Internet", "uptodate": "La dernière version (%s) est déjà installée.", diff --git a/src/lang/zh.json b/src/lang/zh.json index 2976eed..be8cfbb 100644 --- a/src/lang/zh.json +++ b/src/lang/zh.json @@ -43,6 +43,7 @@ "current": "当前版本:", "download_done": "下载完毕!解压中...", "downloading": "下载中...", + "failed": "安装/更新 失败!", "finished": "安装/更新 完成!", "no_internet": "无互联网连接", "uptodate": "最新版本 (%s) 已安装, 跳过更新.", diff --git a/src/modules/gamepath.js b/src/modules/gamepath.js index 5a5f922..65676a4 100644 --- a/src/modules/gamepath.js +++ b/src/modules/gamepath.js @@ -45,18 +45,20 @@ ipcMain.on("wrong-path", () => { }) ipcMain.on("found-missing-perms", async (e, selected_gamepath) => { + gamepath.setting = true; await win().alert(lang("gui.gamepath.found_missing_perms") + selected_gamepath); ipcMain.emit("setpath", null, false, true); }) ipcMain.on("missing-perms", async (e, selected_gamepath) => { + gamepath.setting = true; await win().alert(lang("gui.gamepath.missing_perms") + selected_gamepath); ipcMain.emit("setpath"); }) ipcMain.on("gamepath-lost-perms", async (e, selected_gamepath) => { - if (! gamepath.setting) { - gamepath.setting = true; + if (! gamepath.setting && gamepath.lost_perms != selected_gamepath) { + gamepath.lost_perms = selected_gamepath; await win().alert(lang("gui.gamepath.lost_perms") + selected_gamepath); ipcMain.emit("setpath"); } @@ -80,17 +82,21 @@ gamepath.exists = (folder) => { // returns false if the user doesn't have read/write permissions to the // selected gamepath, if no gamepath is set, then this will always // return `false`, handle that correctly! -gamepath.has_perms = (folder) => { +gamepath.has_perms = (folder = settings().gamepath) => { if (! gamepath.exists(folder)) { return false; } try { fs.accessSync( - folder || settings().gamepath, + folder, fs.constants.R_OK | fs.constants.W_OK ) + let test_file_path = path.join(folder, ".viper_test"); + fs.writeFileSync(test_file_path, ""); + fs.unlinkSync(test_file_path); + return true; } catch (err) { return false; @@ -163,6 +169,8 @@ gamepath.set = async (win, force_dialog) => { return gamepath.setting = false; } + delete gamepath.lost_perms; + if (! fs.existsSync(path.join(res.filePaths[0], "Titanfall2.exe"))) { ipcMain.emit("wrong-path"); return gamepath.setting = false; diff --git a/src/modules/update.js b/src/modules/update.js index c001ba8..7469e02 100644 --- a/src/modules/update.js +++ b/src/modules/update.js @@ -401,9 +401,32 @@ 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 + ")"; + + 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; |