Skip to content

Commit

Permalink
Fix for nested multi WACZ loading (#216)
Browse files Browse the repository at this point in the history
Fix regression introduced during TypeScript conversion
- remove unneeded size var that default to 0, prevented a full load
since never null
- use length instead of size (initial state set to null) in base class
- fixes #215
  • Loading branch information
ikreymer authored Nov 22, 2024
1 parent 18f4b9e commit e9a15d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webrecorder/wabac",
"version": "2.20.6",
"version": "2.20.7",
"main": "index.js",
"type": "module",
"exports": {
Expand Down
9 changes: 3 additions & 6 deletions src/wacz/ziprangereader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ export class ZipRangeReader {
export class ZipBlockLoader extends BaseLoader {
zipreader: ZipRangeReader;
filename: string;
size = 0;

constructor(zipreader: ZipRangeReader, filename: string) {
super(true);
Expand All @@ -442,7 +441,7 @@ export class ZipBlockLoader extends BaseLoader {
async doInitialFetch(tryHead = false) {
await this.zipreader.load();

this.size = this.zipreader.getCompressedSize(this.filename);
this.length = this.zipreader.getCompressedSize(this.filename);

let stream: ReadableStream<Uint8Array> | null = null;

Expand All @@ -459,13 +458,11 @@ export class ZipBlockLoader extends BaseLoader {
}

async getLength() {
// [TODO]
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (this.size === null) {
if (this.length === null) {
await this.doInitialFetch(true);
}

return this.size;
return this.length || 0;
}

async getRange(
Expand Down

0 comments on commit e9a15d2

Please sign in to comment.