aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-02-12 23:18:27 +0100
committerGitHub <noreply@github.com>2022-02-12 23:18:27 +0100
commitb2f826a39e8ecf77f85ca56906758edaa3f1dac3 (patch)
treef4a229d846546d669606f6224d03b186533eb64c
parentee1dcc2b7cd3ba615ee0ae0be76b6ca32f495863 (diff)
parent564694b47e8218b7b9991c844160c0c33d536256 (diff)
downloadViper-b2f826a39e8ecf77f85ca56906758edaa3f1dac3.tar.gz
Viper-b2f826a39e8ecf77f85ca56906758edaa3f1dac3.zip
Merge pull request #73 from Alystrasz/fix/excluded-files
fix: Excluded files
-rw-r--r--src/utils.js43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/utils.js b/src/utils.js
index 842ff99..1448007 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -202,6 +202,19 @@ function getTF2Version() {
}
}
+
+// Renames excluded files to their original name
+function restoreExcludedFiles() {
+ for (let i = 0; i < settings.excludes.length; i++) {
+ let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]);
+ if (fs.existsSync(exclude + ".excluded")) {
+ fs.renameSync(exclude + ".excluded", exclude)
+ }
+ }
+}
+// At start, restore excluded files who might have been created by an incomplete update process.
+restoreExcludedFiles();
+
// Installs/Updates Northstar
//
// If Northstar is already installed it'll be an update, otherwise it'll
@@ -212,14 +225,6 @@ function getTF2Version() {
// <file>.excluded, then rename them back after the extraction. The
// unzip module does not support excluding files directly.
async function update() {
- // Renames excluded files to <file>.excluded
- for (let i = 0; i < settings.excludes.length; i++) {
- let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]);
- if (fs.existsSync(exclude)) {
- fs.renameSync(exclude, exclude + ".excluded")
- }
- }
-
ipcMain.emit("ns-update-event", "cli.update.checking");
console.log(lang("cli.update.checking"));
var version = getNSVersion();
@@ -241,6 +246,14 @@ async function update() {
ipcMain.emit("ns-update-event", "cli.update.downloading");
}
+ // Renames excluded files to <file>.excluded
+ for (let i = 0; i < settings.excludes.length; i++) {
+ let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]);
+ if (fs.existsSync(exclude)) {
+ fs.renameSync(exclude, exclude + ".excluded")
+ }
+ }
+
// Start the download of the zip
https.get(requests.getLatestNsVersionLink(), (res) => {
let stream = fs.createWriteStream(settings.zip);
@@ -263,16 +276,10 @@ async function update() {
// installing Northstar.
fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath}))
.on("finish", () => {
- fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), latestAvailableVersion);
- ipcMain.emit("getversion");
-
- // Renames excluded files to their original name
- for (let i = 0; i < settings.excludes.length; i++) {
- let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]);
- if (fs.existsSync(exclude + ".excluded")) {
- fs.renameSync(exclude + ".excluded", exclude)
- }
- }
+ fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), latestAvailableVersion);
+ ipcMain.emit("getversion");
+
+ restoreExcludedFiles();
ipcMain.emit("guigetmods");
ipcMain.emit("ns-update-event", "cli.update.uptodate.short");