From 2d5e71e77edc00c9378f5a936825f48d8f895fab Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sun, 4 Aug 2024 23:40:57 +0200 Subject: [PATCH 01/12] fix: call correct method for renderer ipc toast event --- src/app/js/toasts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 5ae62ca65db09112f608892e595334e50b8cd4f7 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sun, 4 Aug 2024 23:45:15 +0200 Subject: [PATCH 02/12] feat: add error handler for streaming unzip --- src/app/js/update.js | 32 ++++++++++++++++++++++++++++++-- src/modules/update.js | 29 ++++++++++++++++++++++++++++- 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; From f59e329533d785695c5286104e01103c942849f8 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sun, 4 Aug 2024 23:45:49 +0200 Subject: [PATCH 03/12] lang: add english keys for unzip error handling --- src/lang/en.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lang/en.json b/src/lang/en.json index f968f73..e95d890 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" @@ -275,7 +276,8 @@ "missing_launch_command": "There's currently no custom launch command set, one has to be configured to launch", "missing_steam": "Can't launch with Steam directly, as it doesn't seem to be installed", "missing_flatpak": "Can't launch with Flatpak, as it doesn't seem to be installed", - "missing_flatpak_steam": "Can't launch with the Flatpak version of Steam, as it doesn't seem to be installed" + "missing_flatpak_steam": "Can't launch with the Flatpak version of Steam, as it doesn't seem to be installed", + "permission_denied": "Unable to extract Northstar to your game directory" } } }, From 8fc85282633a622866f3e6e38140084a17dee38f Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Mon, 5 Aug 2024 19:33:38 +0200 Subject: [PATCH 04/12] feat: test gamepath permissions by creating a file --- src/modules/gamepath.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/gamepath.js b/src/modules/gamepath.js index 5a5f922..0209d1b 100644 --- a/src/modules/gamepath.js +++ b/src/modules/gamepath.js @@ -91,6 +91,10 @@ gamepath.has_perms = (folder) => { fs.constants.R_OK | fs.constants.W_OK ) + let test_file_path = path.join(folder || settings().gamepath, ".viper_test"); + fs.writeFileSync(test_file_path, ""); + fs.unlinkSync(test_file_path); + return true; } catch (err) { return false; From 83cc8a62ca9773bdf194175f6e6c6b80a7795f90 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Mon, 5 Aug 2024 19:54:38 +0200 Subject: [PATCH 05/12] chore: set default folder argument --- src/modules/gamepath.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/gamepath.js b/src/modules/gamepath.js index 0209d1b..1e1153e 100644 --- a/src/modules/gamepath.js +++ b/src/modules/gamepath.js @@ -80,18 +80,18 @@ 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 || settings().gamepath, ".viper_test"); + let test_file_path = path.join(folder, ".viper_test"); fs.writeFileSync(test_file_path, ""); fs.unlinkSync(test_file_path); From 94714507d6132518a498ee373cfae77153aa3221 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sat, 10 Aug 2024 10:18:30 +0200 Subject: [PATCH 06/12] chore: prevent gamepath permission alert from reopening on same gamepath Co-authored-by: 0neGal --- src/modules/gamepath.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/gamepath.js b/src/modules/gamepath.js index 1e1153e..db669c1 100644 --- a/src/modules/gamepath.js +++ b/src/modules/gamepath.js @@ -55,8 +55,8 @@ ipcMain.on("missing-perms", async (e, selected_gamepath) => { }) 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"); } @@ -167,6 +167,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; From 7f90d57abc197930ef4e4bfd65b83fdc5934d1d5 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Mon, 5 Aug 2024 20:50:55 +0200 Subject: [PATCH 07/12] fix: prevent multiple missing-perms routines from starting --- src/modules/gamepath.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/gamepath.js b/src/modules/gamepath.js index db669c1..65676a4 100644 --- a/src/modules/gamepath.js +++ b/src/modules/gamepath.js @@ -45,11 +45,13 @@ 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"); }) From 846b7c915e96402da4c3b12e1d02276b4f158634 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sat, 10 Aug 2024 19:58:44 +0200 Subject: [PATCH 08/12] revert some localization changes --- src/lang/en.json | 3 +-- src/modules/update.js | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index e95d890..bf147ab 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -276,8 +276,7 @@ "missing_launch_command": "There's currently no custom launch command set, one has to be configured to launch", "missing_steam": "Can't launch with Steam directly, as it doesn't seem to be installed", "missing_flatpak": "Can't launch with Flatpak, as it doesn't seem to be installed", - "missing_flatpak_steam": "Can't launch with the Flatpak version of Steam, as it doesn't seem to be installed", - "permission_denied": "Unable to extract Northstar to your game directory" + "missing_flatpak_steam": "Can't launch with the Flatpak version of Steam, as it doesn't seem to be installed" } } }, diff --git a/src/modules/update.js b/src/modules/update.js index c792217..7469e02 100644 --- a/src/modules/update.js +++ b/src/modules/update.js @@ -415,10 +415,6 @@ update.northstar = async (force_install) => { 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"), From 2a62e6fe423fa2e9a3bf6b17ebb06958567b2bf3 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sat, 10 Aug 2024 20:00:46 +0200 Subject: [PATCH 09/12] lang: add german translation for update failure --- src/lang/de.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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" From fbc4c6070c20d249c29961ab66b54d84a65161f9 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sat, 10 Aug 2024 20:13:28 +0200 Subject: [PATCH 10/12] lang: add chinese translation for update failure --- src/lang/zh.json | 1 + 1 file changed, 1 insertion(+) 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) 已安装, 跳过更新.", From 52c7f69ab02f7f204c0b3d546e18df144d4f538e Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Thu, 15 Aug 2024 22:48:22 +0200 Subject: [PATCH 11/12] lang: add french translation by CyanPickle --- src/lang/fr.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lang/fr.json b/src/lang/fr.json index 492ba76..e43e70a 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": "Mise à jour échoué !", "finished": "Mise à jour terminée !", "no_internet": "Pas de connexion Internet", "uptodate": "La dernière version (%s) est déjà installée.", From 4ae37f2f520c8082a00cc52f33ea0c1877709d6f Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 19 Aug 2024 15:45:18 +0200 Subject: [PATCH 12/12] Update src/lang/fr.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rémy Raes --- src/lang/fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lang/fr.json b/src/lang/fr.json index e43e70a..c98e143 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -43,7 +43,7 @@ "current": "Version actuelle :", "download_done": "Téléchargement terminé ! Extraction des fichiers...", "downloading": "Téléchargement en cours...", - "failed": "Mise à jour échoué !", + "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.",