fix:unzip error

This commit is contained in:
Tianpao
2025-07-09 10:20:20 +08:00
parent f0ead136fe
commit f2fa0c8bdf
7 changed files with 68 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import inquirer from "inquirer";
import yauzl from "yauzl";
import process from "node:process";
import fs from "node:fs"
import fse from "fs-extra";
import { join, basename, dirname } from "node:path";
import { platform, what_platform } from "./platform/index.js";
@@ -37,7 +38,7 @@ if (!argv) {
}
function initdir(){
if(!fse.existsSync(unzip_path)){
if(!fs.existsSync(unzip_path)){
fse.ensureDirSync(join(unzip_path,"rubbish"))
}
}
@@ -56,7 +57,7 @@ async function main(modpack_path: string) {
if (/\/$/.test(entry.fileName)) {
} else if (entry.fileName.includes("overrides/")) {
const zipfilex = join(unzip_path, zipname,entry.fileName.replace("overrides/",""))
if(!fse.existsSync(zipfilex)){
if(!fs.existsSync(zipfilex)){
zipfile.openReadStream(entry,(err,stream)=>{ //读取overrides文件夹下的所有文件和文件夹
const dir = dirname(zipfilex)
fse.ensureDirSync(dir);

View File

@@ -1,5 +1,5 @@
import cp from "child_process";
import fsExtra from "fs-extra/esm";
import fsExtra from "fs-extra";
import got from "got";
export default async function install(
mcver: string,
@@ -16,4 +16,4 @@ export default async function install(
`java -jar fabric-installer-1.0.1.jar server -mcver ${mcver} -loader ${fabricver}`,
{ cwd: path, stdio: "ignore" }
);
}
}

View File

@@ -1,5 +1,5 @@
import AdmZip from "adm-zip";
import fsExtra from "fs-extra/esm";
import fsExtra from "fs-extra";
import gotx from "got";
import { xfastdownload } from "../utils/utils.js";
import { LOGGER } from "../utils/logger.js";
@@ -73,4 +73,4 @@ export default async function install(
stdio: "ignore",
});
LOGGER.info("安装NeoForge完成");
}
}

View File

@@ -1,5 +1,6 @@
import pMap from "p-map";
import pRetry from "p-retry";
import fs from "node:fs"
import fse from "fs-extra"
import yauzl from "yauzl";
import got from "got";
@@ -35,7 +36,7 @@ export async function fastdownload(data:[string,string]){
const bar = multibar.create(size, 0, {filename: e[1]})
try{
await pRetry(async()=>{
if(!fse.existsSync(e[1])){
if(!fs.existsSync(e[1])){
await got.get(e[0],{
responseType:"buffer",
}).on('downloadProgress',(progress)=>{
@@ -105,7 +106,7 @@ export async function xfastdownload(
url !== null &&
url !== "" &&
path !== null &&
!fse.existsSync(e[1])
!fs.existsSync(e[1])
) {
const res = (await got.get(e[0])).rawBody; //下载文件
await fse.outputFile(e[1], res); //保存文件