fixed edge cases that caused crashes

This commit is contained in:
Hellow 2023-04-04 22:32:53 +02:00
parent 62b0102020
commit 1965ac4cbd

View File

@ -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"):