From 1965ac4cbdff9b6818937b1e4067f50ad1d5d94c Mon Sep 17 00:00:00 2001 From: Hellow Date: Tue, 4 Apr 2023 22:32:53 +0200 Subject: [PATCH] fixed edge cases that caused crashes --- src/music_kraken/pages/support_classes/download_result.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/music_kraken/pages/support_classes/download_result.py b/src/music_kraken/pages/support_classes/download_result.py index 6f6aeeb..a100aff 100644 --- a/src/music_kraken/pages/support_classes/download_result.py +++ b/src/music_kraken/pages/support_classes/download_result.py @@ -18,10 +18,14 @@ class DownloadResult: @property def success_percentage(self) -> float: + if self.total == 0: + return 0 return self.success / self.total @property def failure_percentage(self) -> float: + if self.total == 0: + return 1 return self.fail / self.total @property @@ -30,6 +34,9 @@ class DownloadResult: @property def is_mild_failure(self) -> bool: + if self.is_fatal_error: + return True + return self.failure_percentage > SHOW_DOWNLOAD_ERRORS_THRESHOLD def merge(self, other: "DownloadResult"):