Skip to content

Commit 74b7251

Browse files
authored
Merge pull request #980 from HathorNetwork/fix/division-by-zero-on-progress
fix(util): division by zero when logging progress in some cases
2 parents 7bcc669 + f273716 commit 74b7251

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

hathor/util.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,11 @@ def _tx_progress(iter_tx: Iterator['BaseTransaction'], *, log: 'structlog.stdlib
495495
if total:
496496
progress_ = count / total
497497
elapsed_time = t_log - t_start
498-
remaining_time = LogDuration(elapsed_time / progress_ - elapsed_time)
498+
remaining_time: str | LogDuration
499+
if progress_ == 0:
500+
remaining_time = '?'
501+
else:
502+
remaining_time = LogDuration(elapsed_time / progress_ - elapsed_time)
499503
log.info(
500504
f'loading... {math.floor(progress_ * 100):2.0f}%',
501505
progress=progress_,

0 commit comments

Comments
 (0)