Skip to content

Commit

Permalink
prevent duplicate illustration (skip and failsafe)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Jun 21, 2022
1 parent 7ee2d6e commit aebbefd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/warc2zim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,12 @@ def add_illustration(self, record=None):
for size in (96, 48):
resize_image(illus_fpath, width=size, height=size, method="thumbnail")
with open(illus_fpath, "rb") as fh:
self.creator.add_illustration(size, fh.read())
try:
self.creator.add_illustration(size, fh.read())
except RuntimeError as exc:
if not DUPLICATE_EXC_STR.match(str(exc)):
raise exc
self.indexed_urls.add(src_url)
src_illus_fpath.unlink()

def is_self_redirect(self, record, url):
Expand Down

0 comments on commit aebbefd

Please sign in to comment.