diff --git a/CONTRIBUTORS b/CONTRIBUTORS index b73b5f6ca..c66588274 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -243,14 +243,11 @@ Lee Doughty <32392044+leedoughty@users.noreply.github.com> memchr Max Romanowski Aldlss -<<<<<<< HEAD Hanna Nilsén Elias Johansson Lara Toby Penner Danilo Spillebeen -Matbe766 >>>>>> fcd53376f (qt: normalize large progress totals to kilobytes to avoid QProgressBar overflow (#4341); docs: update CONTRIBUTORS) +Matbe766 ******************** diff --git a/qt/aqt/sync.py b/qt/aqt/sync.py index 3ac09d57a..75bdeca89 100644 --- a/qt/aqt/sync.py +++ b/qt/aqt/sync.py @@ -213,22 +213,12 @@ def on_full_sync_timer(mw: aqt.main.AnkiQt, label: str) -> None: if sync_progress.transferred == sync_progress.total: label = tr.sync_checking() - INT32_MAX = 2_147_483_647 total = sync_progress.total transferred = sync_progress.transferred - # Unknown/zero total -> indeterminate spinner (0..0) - if not total or total <= 0: - value_for_bar = None - max_for_bar = 0 - elif total > INT32_MAX: # scale to kB if too large for int32 - max_for_bar = (total + 1023) // 1024 - value_for_bar = (transferred + 1023) // 1024 - value_for_bar = min(value_for_bar, max_for_bar) - else: - # Small totals -> keep exact bytes - max_for_bar = total - value_for_bar = min(transferred, total) + # Scale both to kilobytes with floor division + max_for_bar = total // 1024 + value_for_bar = transferred // 1024 mw.progress.update( value=value_for_bar,