[downloader:http] fix ZeroDivisionError (#3328)

ensure 'time_elapsed' only get used as divisor
when it is greater than zero
This commit is contained in:
Mike Fährmann
2022-11-30 21:56:18 +01:00
parent fc34f76cc5
commit b4253f69c9

View File

@@ -74,6 +74,8 @@ class HttpDownloader(DownloaderBase):
self.log.warning("Invalid rate limit (%r)", self.rate)
if self.progress is not None:
self.receive = self._receive_rate
if self.progress < 0.0:
self.progress = 0.0
def download(self, url, pathfmt):
try:
@@ -295,7 +297,7 @@ class HttpDownloader(DownloaderBase):
write(data)
if progress is not None:
if time_elapsed >= progress:
if time_elapsed > progress:
self.out.progress(
bytes_total,
bytes_start + bytes_downloaded,