fix: server-error requesting some ranges of zip
Massimo Melina committed
Sep 13, 2025 at 10:21 UTC
5804e8b2dbc4ff3f4ce369b4e014d4162832213c
1 file changed
+6
-6
src/QuickZipStream.ts
+6
-6
@@ -52,19 +52,20 @@ export class QuickZipStream extends Readable {
52
return this.entries.map(x => String(x.pathAsBuffer))
53
}
54
55
- earlyClose() {
55
+ closeStream() {
56
this.finished = true
57
- this.push(null)
57
+ this.push(null) // EOF
58
}
59
60
applyRange(start: number, end: number) {
61
if (end < start)
62
- return this.earlyClose()
62
+ return this.closeStream()
63
this.skip = start
64
this.limit = end - start + 1
65
}
66
67
controlledPush(chunk: number[] | Buffer) {
68
+ if (this.finished) return
69
if (Array.isArray(chunk))
70
chunk = buffer(chunk)
71
this.dataWritten += chunk.length
@@ -82,7 +83,7 @@ export class QuickZipStream extends Readable {
83
84
const ret = this.push(chunk)
85
if (lastBit)
85
- this.earlyClose()
86
+ this.closeStream()
87
return ret
88
}
89
@@ -189,7 +190,6 @@ export class QuickZipStream extends Readable {
190
}
191
192
closeArchive() {
192
- this.finished = true
193
let centralDirOffset = this.dataWritten
194
for (let { size, ts, crc, offset, pathAsBuffer, version, extAttr } of this.entries) {
195
const extra = []
@@ -263,7 +263,7 @@ export class QuickZipStream extends Readable {
263
4, centralDirOffset,
264
2, 0, // comment length
265
])
266
- this.push(null) // EOF
266
+ this.closeStream()
267
}
268
}
269