aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-02-18 22:23:06 +0100
committer0neGal <mail@0negal.com>2022-02-18 22:23:06 +0100
commitd271a1c74cce1ef75672a1ff2888862ee1fc393c (patch)
tree02407710f1ee47f1f849c944b0cca72ab96e8fae /src
parent78a83334f42294fdc0e36c2c44e1fbff7369fd7c (diff)
downloadViper-d271a1c74cce1ef75672a1ff2888862ee1fc393c.tar.gz
Viper-d271a1c74cce1ef75672a1ff2888862ee1fc393c.zip
fix being able to upload any file
Usually utils.js would default to simply unzipping whatever was uploaded if it wasn't a folder, now we check if it has "zip" as the extension, case insensitive. If not simply report back the file wasn't a mod. As opposed to the obscure error you got before this.
Diffstat (limited to 'src')
-rw-r--r--src/utils.js62
1 files changed, 33 insertions, 29 deletions
diff --git a/src/utils.js b/src/utils.js
index 1448007..2ea91cd 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -544,40 +544,44 @@ const mods = {
}
try {
- fs.createReadStream(mod).pipe(unzip.Extract({path: cache}))
- .on("finish", () => {
- setTimeout(() => {
- let manifest = path.join(cache, "manifest.json");
- if (fs.existsSync(manifest)) {
- files = fs.readdirSync(path.join(cache, "mods"));
- if (fs.existsSync(path.join(cache, "mods/mod.json"))) {
- if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest, true)) {
- return true;
- }
- } else {
- for (let i = 0; i < files.length; i++) {
- let mod = path.join(cache, "mods", files[i]);
- if (fs.statSync(mod).isDirectory()) {
- setTimeout(() => {
- if (mods.install(mod, false, manifest)) {return true};
- }, 1000)
+ if (mod.replace(/.*\./, "").toLowerCase() == "zip") {
+ fs.createReadStream(mod).pipe(unzip.Extract({path: cache}))
+ .on("finish", () => {
+ setTimeout(() => {
+ let manifest = path.join(cache, "manifest.json");
+ if (fs.existsSync(manifest)) {
+ files = fs.readdirSync(path.join(cache, "mods"));
+ if (fs.existsSync(path.join(cache, "mods/mod.json"))) {
+ if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest, true)) {
+ return true;
+ }
+ } else {
+ for (let i = 0; i < files.length; i++) {
+ let mod = path.join(cache, "mods", files[i]);
+ if (fs.statSync(mod).isDirectory()) {
+ setTimeout(() => {
+ if (mods.install(mod, false, manifest)) {return true};
+ }, 1000)
+ }
}
- }
- if (files.length == 0) {
- ipcMain.emit("failedmod");
- return notamod();
+ if (files.length == 0) {
+ ipcMain.emit("failedmod");
+ return notamod();
+ }
}
- }
- return notamod();
- }
+ return notamod();
+ }
- if (mods.install(cache)) {
- installed();
- } else {return notamod()}
- }, 1000)
- });
+ if (mods.install(cache)) {
+ installed();
+ } else {return notamod()}
+ }, 1000)
+ });
+ } else {
+ return notamod();
+ }
}catch(err) {return notamod()}
}
},