1
0
Fork 0
forked from svrjs/svrjs

Fix problems with loading .tar.gz mods

This commit is contained in:
Dorian Niemiec 2024-08-27 09:15:15 +02:00
parent 9a5d43d129
commit 33fde81ba1

View file

@ -677,6 +677,33 @@ if (!disableMods) {
".modloader_w" + Math.floor(Math.random() * 65536); ".modloader_w" + Math.floor(Math.random() * 65536);
} }
try {
// Try creating the modloader folder (if not already exists)
try {
fs.mkdirSync(process.dirname + "/temp/" + modloaderFolderName);
} catch (err) {
// If the folder already exists, continue to the next step
if (err.code != "EEXIST") {
// If there was another error, try creating the temp folder and then the modloader folder again
fs.mkdirSync(process.dirname + "/temp");
try {
fs.mkdirSync(process.dirname + "/temp/" + modloaderFolderName);
} catch (err) {
// If there was another error, throw it
if (err.code != "EEXIST") throw err;
}
}
}
// Create a subfolder for the current mod within the modloader folder
fs.mkdirSync(process.dirname + "/temp/" + modloaderFolderName + "/" + modFileRaw);
} catch (err) {
// If there was an error creating the folder, ignore it if it's a known error
if (err.code != "EEXIST" && err.code != "ENOENT") throw err;
// Some other SVR.JS process may have created the files.
}
// Determine if the mod file is a ".tar.gz" file or not // Determine if the mod file is a ".tar.gz" file or not
if (modFile.indexOf(".tar.gz") == modFile.length - 7) { if (modFile.indexOf(".tar.gz") == modFile.length - 7) {
// If it's a ".tar.gz" file, extract its contents using `tar` // If it's a ".tar.gz" file, extract its contents using `tar`