Skip to content

Commit

Permalink
Add patching support for multiWACZ collections (#131)
Browse files Browse the repository at this point in the history
* multiwacz: support patching: allow searching in multiple wacz files if resource not found in initial (perhaps make configurable later by comparing page lists)
bump to 2.16.5

* textIndex: catch empty reader and return empty response
  • Loading branch information
ikreymer authored Jul 11, 2023
1 parent f75a682 commit cf71e56
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dist/sw.js

Large diffs are not rendered by default.

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.16.4",
"version": "2.16.5",
"main": "index.js",
"type": "module",
"license": "AGPL-3.0-or-later",
Expand Down
14 changes: 8 additions & 6 deletions src/wacz/multiwacz.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ export class MultiWACZ extends OnDemandPayloadArchiveDB// implements WACZLoadSou
}

const {reader} = result;
if (!reader) {
return new Response("", {headers});
}

const size = this.waczfiles[waczname].getSizeOf(this.textIndex);

Expand Down Expand Up @@ -756,8 +759,6 @@ export class MultiWACZ extends OnDemandPayloadArchiveDB// implements WACZLoadSou
}
}

const isNavigate = event.request.mode === "navigate";

let hash = pageId;
let waczname = null;

Expand All @@ -771,17 +772,18 @@ export class MultiWACZ extends OnDemandPayloadArchiveDB// implements WACZLoadSou
resp = await super.getResource(request, prefix, event, {waczname});
}

if (resp || !isNavigate) {
return resp;
}

let foundHash = null;

for (const [name, file] of Object.entries(this.waczfiles)) {
if (file.fileType !== WACZ_LEAF) {
continue;
}

// already checked this file above, don't check again
if (file.hash === hash) {
continue;
}

resp = await super.getResource(request, prefix, event, {waczname: name, noFuzzyCheck: true});
if (resp) {
waczname = name;
Expand Down

0 comments on commit cf71e56

Please sign in to comment.