aboutsummaryrefslogtreecommitdiff
path: root/src/modules/packages.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-07-16 18:58:10 +0200
committer0neGal <mail@0negal.com>2023-07-16 18:58:10 +0200
commit241f5528c749772b62095bc9b025906f84a68810 (patch)
tree54b9c8810ac316f8b3f39f060dda5f2992008582 /src/modules/packages.js
parent4434c1d4c8b24db2a3ca8ec2aaf629ce66956034 (diff)
downloadViper-241f5528c749772b62095bc9b025906f84a68810.tar.gz
Viper-241f5528c749772b62095bc9b025906f84a68810.zip
remove mods in old folder if installing to new one
If you're now installing a mod that's currently in the `mods/` folder it'll remove that, then install the new one to `packages/` with the new naming scheme and everything.
Diffstat (limited to 'src/modules/packages.js')
-rw-r--r--src/modules/packages.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/modules/packages.js b/src/modules/packages.js
index 8d40de1..4410192 100644
--- a/src/modules/packages.js
+++ b/src/modules/packages.js
@@ -4,6 +4,7 @@ const unzip = require("unzipper");
const app = require("electron").app;
const https = require("follow-redirects").https;
+const mods = require("./mods");
const json = require("./json");
const win = require("./window");
const settings = require("./settings");
@@ -195,7 +196,19 @@ packages.install = async (url, author, package_name, version) => {
console.log("Verified package:", name);
- console.log("Deleting older version, if it exists:", name);
+ console.log("Deleting older version(s), if it exists:", name);
+ // check and delete any mod with the name package details in the old
+ // `mods` folder, if there are any at all
+ let mods_list = mods.list().all;
+ for (let i = 0; i < mods_list.length; i++) {
+ let mod = mods_list[i];
+
+ if (mod.ManifestName == package_name) {
+ mods.remove(mod.Name);
+ continue;
+ }
+ }
+
packages.remove(author, package_name, version);
console.log("Moving package:", name);
@@ -217,7 +230,7 @@ packages.download = async (url, name) => {
let tmp = path.join(app.getPath("cache"), "vipertmp");
let zip_name = name || "package";
- let zip_path = path.join(tmp, `/${zip_name}.zip`);
+ let zip_path = path.join(tmp, `${zip_name}.zip`);
// make sure the temporary folder exists
if (fs.existsSync(tmp)) {