From 25554d7fe8b8b24d70fa8cbd87ae0866feff2878 Mon Sep 17 00:00:00 2001 From: Salem Yaslem Date: Mon, 2 Dec 2024 00:05:51 +0300 Subject: [PATCH] add(#10): support tar.gz format by workaround --- composables/worker/7zip-manager.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/composables/worker/7zip-manager.ts b/composables/worker/7zip-manager.ts index 50dba85..61456fa 100644 --- a/composables/worker/7zip-manager.ts +++ b/composables/worker/7zip-manager.ts @@ -20,6 +20,7 @@ export class SevenZipManager { sevenZip?: SevenZipModule; consoleOutputBuffer: string[] = []; archiveName: string = ""; + originalName: string = ""; constructor() { this.init(); @@ -47,7 +48,8 @@ export class SevenZipManager { async loadArchive(file: File) { if (!this.sevenZip) return; - this.archiveName = file.name; + this.originalName = file.name; + this.archiveName = file.name.toLocaleLowerCase(); const stream = this.sevenZip.FS.open(this.archiveName, "w+"); let archiveData = new Uint8Array(await file.arrayBuffer()); @@ -55,6 +57,12 @@ export class SevenZipManager { this.sevenZip.FS.write(stream, archiveData, 0, archiveData.byteLength); this.sevenZip.FS.close(stream); + // workaround to support tar.gz formats + if (this.archiveName.endsWith(".tar.gz")) { + this.execute(["x", "-y", this.archiveName, `-o${this.archiveName.replace(".tar.gz", ".tar")}`]); + this.archiveName = this.archiveName.replace(".tar.gz", ".tar"); + } + // 7zip get files list let filesString = this.execute(["l", "-ba", this.archiveName]);