From c6a7079dc18c9bd32efcbb27cdc211de90a61075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matilda=20Bergstr=C3=B6m?= Date: Tue, 30 Sep 2025 10:57:06 +0200 Subject: [PATCH] revert: keep ProgressManager generic; do scaling only in full sync --- qt/aqt/sync.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/qt/aqt/sync.py b/qt/aqt/sync.py index 9b29ada20..3ac09d57a 100644 --- a/qt/aqt/sync.py +++ b/qt/aqt/sync.py @@ -209,11 +209,30 @@ def on_full_sync_timer(mw: aqt.main.AnkiQt, label: str) -> None: return sync_progress = progress.full_sync + # If we've reached total, show the "checking" label 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) + mw.progress.update( - value=sync_progress.transferred, - max=sync_progress.total, + value=value_for_bar, + max=max_for_bar, process=False, label=label, )