chore(HM):使解压功能可用

This commit is contained in:
Tianpao
2026-01-01 00:26:14 +08:00
parent 81ae7bec50
commit c9a7b6f303
9 changed files with 278 additions and 142 deletions

View File

@@ -1,6 +1,7 @@
import fs from "node:fs"
import crypto from "node:crypto"
import { yauzl_promise } from "./yauzl.promise.js"
//import { yauzl_promise } from "./yauzl.promise.js"
import { Azip } from "./ziplib.js"
import got from "got"
import { Utils } from "./utils.js"
import config from "./config.js"
@@ -56,6 +57,7 @@ export class DeEarth{
const result = [...new Set(hash.concat(mixins))]
//console.log(result)
result.forEach(async e=>{
console.log(e)
await fs.promises.rename(`${e}`,`${this.movepath}/${e}`.replace(this.modspath,""))
//await fs.promises.rename(`${this.modspath}/${e}`,`${this.movepath}/${e}`)
})
@@ -136,9 +138,9 @@ export class DeEarth{
const data = fs.readFileSync(file)
const sha1 = crypto.createHash('sha1').update(data).digest('hex') //Get Hash
const mxarr:{name:string,data:string}[] = []
const mixins = (await yauzl_promise(data)).forEach(async e=>{ //Get Mixins Info to check
if(e.fileName.endsWith(".mixins.json")&&!e.fileName.includes("/")){
mxarr.push({name:e.fileName,data:(await e.ReadEntry).toString()})
const mixins = (Azip(data)).forEach(async e=>{ //Get Mixins Info to check
if(e.entryName.endsWith(".mixins.json")&&!e.entryName.includes("/")){
mxarr.push({name:e.entryName,data:(await e.getData()).toString()})
}
})
arr.push({filename:file,hash:sha1,mixins:mxarr})