fix: zstd decompressor

This commit is contained in:
xxnuo
2026-01-01 16:59:08 +08:00
parent 62fa6d4ad1
commit facb5b92b4
3 changed files with 8 additions and 8 deletions

View File

@@ -7,8 +7,8 @@
"dependencies": {
"express": "^4.21.2",
"express-validator": "^7.3.1",
"fzstd": "^0.1.1",
"swagger-ui-express": "^5.0.1",
"zstd-wasm-decoder": "^0.2.0",
},
"devDependencies": {
"@tsoa/runtime": "^7.0.0-alpha.0",
@@ -264,6 +264,8 @@
"function-bind": ["function-bind@1.1.2", "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
"fzstd": ["fzstd@0.1.1", "https://registry.npmmirror.com/fzstd/-/fzstd-0.1.1.tgz", {}, "sha512-dkuVSOKKwh3eas5VkJy1AW1vFpet8TA/fGmVA5krThl8YcOVE/8ZIoEA1+U1vEn5ckxxhLirSdY837azmbaNHA=="],
"get-caller-file": ["get-caller-file@2.0.5", "https://registry.npmmirror.com/get-caller-file/-/get-caller-file-2.0.5.tgz", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="],
"get-intrinsic": ["get-intrinsic@1.3.0", "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
@@ -444,8 +446,6 @@
"yargs-parser": ["yargs-parser@21.1.1", "https://registry.npmmirror.com/yargs-parser/-/yargs-parser-21.1.1.tgz", {}, "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw=="],
"zstd-wasm-decoder": ["zstd-wasm-decoder@0.2.3", "https://registry.npmmirror.com/zstd-wasm-decoder/-/zstd-wasm-decoder-0.2.3.tgz", {}, "sha512-Sv/4PqvQNQT20cA+dk9K3lwkLxNfYzKEGb99gyfw52HdDQpM0CeKTRDqIenDgCqvOif2XaOLc3CdqE1SM2ucSQ=="],
"@isaacs/cliui/string-width": ["string-width@5.1.2", "https://registry.npmmirror.com/string-width/-/string-width-5.1.2.tgz", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="],
"@isaacs/cliui/strip-ansi": ["strip-ansi@7.1.2", "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-7.1.2.tgz", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA=="],

View File

@@ -42,8 +42,8 @@
"dependencies": {
"express": "^4.21.2",
"express-validator": "^7.3.1",
"swagger-ui-express": "^5.0.1",
"zstd-wasm-decoder": "^0.2.0"
"fzstd": "^0.1.1",
"swagger-ui-express": "^5.0.1"
},
"engines": {
"node": ">=18.0.0"

View File

@@ -1,6 +1,6 @@
import fs from 'fs/promises'
import path from 'path'
import { decompressSync } from 'zstd-wasm-decoder'
import { decompress } from 'fzstd'
import { ResourceLoader } from '@/core/loader.js'
import { FileSystem } from '@/core/interfaces.js'
@@ -34,8 +34,8 @@ export class Downloader {
async decompress(inputPath: string, outputPath: string): Promise<void> {
const compressedData = await fs.readFile(inputPath)
const decompressed = decompressSync(new Uint8Array(compressedData))
await fs.writeFile(outputPath, Buffer.from(decompressed))
const decompressed = decompress(compressedData)
await fs.writeFile(outputPath, decompressed)
}
private async downloadBinary(url: string): Promise<Buffer> {