mirror of
https://github.com/xlmnxp/extractify.zip.git
synced 2025-04-02 07:44:55 +03:00
Compare commits
2 Commits
ffc453f93a
...
09d57d848e
Author | SHA1 | Date | |
---|---|---|---|
09d57d848e | |||
25554d7fe8 |
@ -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]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user