Prevent division by 0 if total download size is 0

This can happen if the downloads are all so small that it gets rounded to 0kB.

Fixes Sentry issue CURA-ZM.
This commit is contained in:
Ghostkeeper 2020-07-06 17:23:58 +02:00
parent f0456526b3
commit 3032221b70
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
3 changed files with 7 additions and 3 deletions

View file

@ -120,6 +120,10 @@ class DownloadPresenter:
received += item["received"]
total += item["total"]
if total == 0: # Total download size is 0, or unknown, or there are no progress items at all.
self._progress_message.setProgress(100.0)
return
self._progress_message.setProgress(100.0 * (received / total)) # [0 .. 100] %
def _onError(self, package_id: str) -> None: