Skip to content

Commit

Permalink
Move zip page file references into conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Apr 11, 2024
1 parent 2e23089 commit 97a1b02
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions wacz/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ def create_wacz(res):
index_file = zipfile.ZipInfo("indexes/index.idx", now())
index_file.compress_type = zipfile.ZIP_DEFLATED

pages_jsonl = zipfile.ZipInfo("pages/pages.jsonl", now())
extra_pages_jsonl = zipfile.ZipInfo("pages/extraPages.jsonl", now())

index_buff = BytesIO()

text_wrap = TextIOWrapper(index_buff, "utf-8", write_through=True)
Expand All @@ -192,6 +189,7 @@ def create_wacz(res):
return 1

with open(res.pages, "rb") as fh:
pages_jsonl = zipfile.ZipInfo("pages/pages.jsonl", now())
with wacz.open(pages_jsonl, "w") as pages_file:
shutil.copyfileobj(fh, pages_file)

Expand All @@ -216,6 +214,7 @@ def create_wacz(res):
if res.copy_pages:
print("Copying passed extraPages.jsonl file to WACZ")
if validate_pages_jsonl_file(res.extra_pages):
extra_pages_jsonl = zipfile.ZipInfo("pages/extraPages.jsonl", now())
with open(res.extra_pages, "rb") as fh:
with wacz.open(extra_pages_jsonl, "w") as extra_pages_file:
shutil.copyfileobj(fh, extra_pages_file)
Expand Down

0 comments on commit 97a1b02

Please sign in to comment.