aboutsummaryrefslogtreecommitdiff
path: root/src/modules/update.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-03-09 16:11:18 +0100
committer0neGal <mail@0negal.com>2023-03-09 16:13:50 +0100
commitd59cbd05f3d238b69458df458b58b67b439f0590 (patch)
tree40fefe6e57da4069c81c386816dd586974b0769c /src/modules/update.js
parente666a607a66b560036c853b3a163aedc1b5ab638 (diff)
downloadViper-d59cbd05f3d238b69458df458b58b67b439f0590.tar.gz
Viper-d59cbd05f3d238b69458df458b58b67b439f0590.zip
download Northstar to <cache_dir>/vipertmp
"cache_dir" being wherever your OS puts it's cache, it's the same place mods.js uses to download mods. This prevents cluttering up the gamepath with temporary files.
Diffstat (limited to 'src/modules/update.js')
-rw-r--r--src/modules/update.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/modules/update.js b/src/modules/update.js
index 82a6df1..534a5af 100644
--- a/src/modules/update.js
+++ b/src/modules/update.js
@@ -161,7 +161,7 @@ update.northstar = async () => {
let ns_version = version.northstar();
const latest_version = await requests.getLatestNsVersion();
- console.log(latest_version)
+
if (latest_version == false) {
ipcMain.emit("ns-update-event", "cli.update.noInternet");
return;
@@ -187,7 +187,20 @@ update.northstar = async () => {
exclude_files();
// start the download of the zip
- https.get(requests.getLatestNsVersionLink(), (res) => {
+ https.get(requests.getLatestNsVersionLink() + "asd", (res) => {
+ let tmp = path.dirname(settings.zip);
+
+ if (fs.existsSync(tmp)) {
+ if (! fs.statSync(tmp).isDirectory()) {
+ fs.rmSync(tmp);
+ }
+ } else {
+ fs.mkdirSync(tmp);
+ if (fs.existsSync(settings.zip)) {
+ fs.rmSync(settings.zip);
+ }
+ }
+
let stream = fs.createWriteStream(settings.zip);
res.pipe(stream);