|
@@ -3004,7 +3004,7 @@ export class Unzip {
|
|
*/
|
|
*/
|
|
push(chunk: Uint8Array, final?: boolean) {
|
|
push(chunk: Uint8Array, final?: boolean) {
|
|
if (!this.onfile) throw 'no callback';
|
|
if (!this.onfile) throw 'no callback';
|
|
- if (!this.k) throw 'stream finished';
|
|
|
|
|
|
+ if (!this.p) throw 'stream finished';
|
|
if (this.c > 0) {
|
|
if (this.c > 0) {
|
|
const len = Math.min(this.c, chunk.length);
|
|
const len = Math.min(this.c, chunk.length);
|
|
const toAdd = chunk.subarray(0, len);
|
|
const toAdd = chunk.subarray(0, len);
|
|
@@ -3039,6 +3039,7 @@ export class Unzip {
|
|
else if (dd) sc = -1;
|
|
else if (dd) sc = -1;
|
|
i += es;
|
|
i += es;
|
|
this.c = sc;
|
|
this.c = sc;
|
|
|
|
+ let d: UnzipDecoder;
|
|
const file = {
|
|
const file = {
|
|
name: fn,
|
|
name: fn,
|
|
compression: cmp,
|
|
compression: cmp,
|
|
@@ -3048,15 +3049,15 @@ export class Unzip {
|
|
else {
|
|
else {
|
|
const ctr = this.o[cmp];
|
|
const ctr = this.o[cmp];
|
|
if (!ctr) throw 'unknown compression type ' + cmp;
|
|
if (!ctr) throw 'unknown compression type ' + cmp;
|
|
- const d = sc < 0 ? new ctr(fn) : new ctr(fn, sc, su);
|
|
|
|
|
|
+ d = sc < 0 ? new ctr(fn) : new ctr(fn, sc, su);
|
|
d.ondata = (err, dat, final) => { file.ondata(err, dat, final); }
|
|
d.ondata = (err, dat, final) => { file.ondata(err, dat, final); }
|
|
for (const dat of chks) d.push(dat, false);
|
|
for (const dat of chks) d.push(dat, false);
|
|
- if (this.k[0] == chks) this.d = d;
|
|
|
|
|
|
+ if (this.k[0] == chks && this.c) this.d = d;
|
|
else d.push(et, true);
|
|
else d.push(et, true);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
terminate: () => {
|
|
terminate: () => {
|
|
- if (this.k[0] == chks && this.d.terminate) this.d.terminate();
|
|
|
|
|
|
+ if (d && d.terminate) d.terminate();
|
|
}
|
|
}
|
|
} as UnzipFile;
|
|
} as UnzipFile;
|
|
if (sc >= 0) file.size = sc, file.originalSize = su;
|
|
if (sc >= 0) file.size = sc, file.originalSize = su;
|
|
@@ -3084,7 +3085,7 @@ export class Unzip {
|
|
}
|
|
}
|
|
if (final) {
|
|
if (final) {
|
|
if (this.c) throw 'invalid zip file';
|
|
if (this.c) throw 'invalid zip file';
|
|
- this.k = null;
|
|
|
|
|
|
+ this.p = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|