Skip to content

Commit 35f6118

Browse files
committed
refactor: use creator object can_finish primitive instead of manual unlink
1 parent 7aa0524 commit 35f6118

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/devdocs2zim/generator.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ def generate_zim(
496496
)
497497

498498
# Start creator early to detect problems early.
499-
try:
500-
with creator as started_creator:
499+
with creator as started_creator:
500+
try:
501501
logger.info(" Fetching the index...")
502502
index = self.devdocs_client.get_index(doc_metadata.slug)
503503
logger.debug(f" The index has {len(index.entries)} entries.")
@@ -513,12 +513,10 @@ def generate_zim(
513513
db=db,
514514
common_resources=common_resources,
515515
)
516-
except Exception:
517-
logger.error(f" Deleting incomplete ZIM file: {zim_path}")
518-
zim_path.unlink(missing_ok=True)
516+
except Exception:
517+
started_creator.can_finish = False
519518

520-
# bubble the exception to entrypoint and exit with code 1
521-
raise
519+
raise
522520

523521
return zim_path
524522

0 commit comments

Comments
 (0)