From 22bdaf57419702007ea27110fe01201a692a8641 Mon Sep 17 00:00:00 2001 From: Salem Yaslem Date: Sat, 22 Jul 2023 05:06:16 +0300 Subject: [PATCH] use fs.readFile instead of fs.lookupPath --- composables/worker/7zip-manager.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/composables/worker/7zip-manager.ts b/composables/worker/7zip-manager.ts index aaa1b06..190a15b 100644 --- a/composables/worker/7zip-manager.ts +++ b/composables/worker/7zip-manager.ts @@ -146,19 +146,18 @@ export class SevenZipManager { if (!this.sevenZip) return; file = typeof file === "string" ? JSON.parse(file) : file; - this.sevenZip.FS.chdir("/"); - // extract file from archive this.execute(['x', '-y', this.archiveName, file.path.substring(1)]); + this.sevenZip.FS.chmod(file.path, 0o777); - const { node } = this.sevenZip.FS.lookupPath('/'); - const buffer = node.contents[file.path.substring(1)].contents; + // get file buffer + const buffer = this.sevenZip.FS.readFile(file.path); - const blob = new Blob([buffer as unknown as Uint8Array], { type: mime.getType(file.extension!) || "application/octet-stream" }); + const blob = new Blob([buffer], { type: mime.getType(file.extension!) || "application/octet-stream" }); const blobUrl = URL.createObjectURL(blob); // remove the file after extract local blob url - this.sevenZip.FS.unlink(file.path.substring(1)); + this.sevenZip.FS.unlink(file.path); return blobUrl; }