Browse Source

Fix unzip error in post-termination extraction

101arrowz 4 years ago
parent
commit
147d47409e
4 changed files with 7 additions and 5 deletions
  1. 3 0
      README.md
  2. 1 1
      package.json
  3. 2 2
      src/index.ts
  4. 1 2
      test/util.ts

+ 3 - 0
README.md

@@ -339,6 +339,9 @@ unzipper.onfile = file => {
   }
 };
 
+// Try to keep under 5,000 files per chunk to avoid stack limit errors
+// For example, if all files are a few kB, multi-megabyte chunks are OK
+// If files are mostly under 100 bytes, 64kB chunks are the limit
 unzipper.push(zipChunk1);
 unzipper.push(zipChunk2);
 unzipper.push(zipChunk3, true);

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "fflate",
-  "version": "0.6.5",
+  "version": "0.6.6",
   "description": "High performance (de)compression in an 8kB package",
   "main": "./lib/index.cjs",
   "module": "./esm/browser.js",

+ 2 - 2
src/index.ts

@@ -3004,7 +3004,7 @@ export class Unzip {
    */
   push(chunk: Uint8Array, final?: boolean) {
     if (!this.onfile) throw 'no callback';
-    if (!this.k) throw 'stream finished';
+    if (!this.p) throw 'stream finished';
     if (this.c > 0) {
       const len = Math.min(this.c, chunk.length);
       const toAdd = chunk.subarray(0, len);
@@ -3084,7 +3084,7 @@ export class Unzip {
     }
     if (final) {
       if (this.c) throw 'invalid zip file';
-      this.k = null;
+      this.p = null;
     }
   }
 

+ 1 - 2
test/util.ts

@@ -15,8 +15,7 @@ const testFiles = {
 
 const testZipFiles = {
   model3D: 'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/models/kmz/Box.kmz',
-  largeModel3D: 'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/models/3mf/truck.3mf',
-  repo: 'https://codeload.github.com/parcel-bundler/parcel/zip/v2'
+  largeModel3D: 'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/models/3mf/truck.3mf'
 };
 
 const dlCached = async <T extends Record<string, string | Buffer>>(files: T) => {