fix:unzip无添加、遇到Mixin错误会崩溃

This commit is contained in:
Tianpao
2026-02-03 23:59:24 +08:00
parent a643f6373c
commit 9309303036
2 changed files with 20 additions and 3 deletions

View File

@@ -181,15 +181,21 @@ export class Dex {
let index = 1;
for await (const entry of zip) {
const isDir = entry.fileName.endsWith("/");
console.log(index, entry.fileName);
logger.info(`index: ${index}, fileName: ${entry.fileName}`);
if (isDir) {
if (this._ublack(entry.fileName)) {
this.message.unzip(entry.fileName, zip.length, index);
index++;
continue;
}
await fs.promises.mkdir(`${instancePath}/${entry.fileName}`, {
recursive: true,
});
} else if (entry.fileName.startsWith("overrides/")) {
// 跳过黑名单文件
if (this._ublack(entry.fileName)) {
console.log("Skip blacklist file", entry.fileName);
logger.info("Skip blacklist file", entry.fileName);
this.message.unzip(entry.fileName, zip.length, index);
index++;
continue;
}
@@ -222,7 +228,10 @@ export class Dex {
"overrides/options.txt",
"shaderpacks",
"essential",
"resourcepacks"
"resourcepacks",
"PCL",
"CustomSkinLoader",
"overrides"
];
return blacklist.some(item => filename.includes(item));

View File

@@ -113,8 +113,10 @@ export class DeEarth {
const serverMods: string[] = [];
const modIds: string[] = [];
const map: Map<string, string> = new Map();
try{
for (const file of this.files) {
for (const info of file.infos) {
try{
const config = JSON.parse(info.data);
const keys = Object.keys(config);
if (keys.includes("id")) {
@@ -124,6 +126,9 @@ export class DeEarth {
modIds.push(config.mods[0].modId);
map.set(config.mods[0].modId, file.filename);
}
}catch(error: any){
logger.error("Checking mod info file failed, filename: " + file.filename, error);
}
}
}
const modids = modIds;
@@ -146,6 +151,9 @@ export class DeEarth {
}
}
}
}catch(error: any){
logger.error("Dexpub check failed", error);
}
return { serverMods, clientMods };
}