Handle mod not found in data export

Handle the case of the mod file not being found from the mod version.
This could happen if the naming scheme is weird or the mod is unpacked.
This commit is contained in:
Hornwitser committed 2021-06-26 17:59:48 +02:00
1 parent 80eae94fe1
commit 90a400b782
1 file changed
+19 -2
+19 -2
View File
@@ -90,7 +90,16 @@ async function loadFile(server, modVersions, modPath) {
}
}
let zip = await loadZip(server, modVersions, mod);
let zip;
try {
zip = await loadZip(server, modVersions, mod);
} catch (err) {
if (err.code === "ENOENT") {
return null;
}
throw err;
}
let file = zip.file(filePath);
if (!file) {
return null;
@@ -310,7 +319,15 @@ async function exportLocale(server, modVersions, modOrder, languageCode) {
continue;
}
let zip = await loadZip(server, modVersions, mod);
let zip;
try {
zip = await loadZip(server, modVersions, mod);
} catch (err) {
if (err.code === "ENOENT") {
continue;
}
throw err;
}
for (let file of zip.file(new RegExp(`locale\\/${languageCode}\\/.*\\.cfg`))) {
let content = await file.async("nodebuffer");
mergeLocale(ini.parse(content.toString("utf8")));