Compare commits

...

2 Commits

View File

@ -5,6 +5,7 @@ import SevenZip, { SevenZipModule } from "7z-wasm";
// @ts-expect-error 7z-wasm have that file but typescript can't find it when query it with url
import SevenZipWasm from "7z-wasm/7zz.wasm?url";
import * as Comlink from "comlink";
import { v4 as randomUUID } from "uuid";
import mime from 'mime';
export interface iFile {
@ -20,6 +21,7 @@ export class SevenZipManager {
sevenZip?: SevenZipModule;
consoleOutputBuffer: string[] = [];
archiveName: string = "";
originalName: string = "";
constructor() {
this.init();
@ -47,6 +49,7 @@ export class SevenZipManager {
async loadArchive(file: File) {
if (!this.sevenZip) return;
this.originalName = file.name;
this.archiveName = file.name;
const stream = this.sevenZip.FS.open(this.archiveName, "w+");
@ -55,6 +58,12 @@ export class SevenZipManager {
this.sevenZip.FS.write(stream, archiveData, 0, archiveData.byteLength);
this.sevenZip.FS.close(stream);
// workaround to support tar.gz and tar.xz formats
if ([".tar.gz", ".tgz", ".tar.xz"].some(ext => this.archiveName.endsWith(ext))) {
this.archiveName = randomUUID();
this.execute(["x", "-y", this.originalName, `-o${this.archiveName}`]);
}
// 7zip get files list
let filesString = this.execute(["l", "-ba", this.archiveName]);