A little fix in the download item for a situation causing a division by zero. 6_0_x

Tue, 08 Sep 2015 18:56:13 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 08 Sep 2015 18:56:13 +0200
branch
6_0_x
changeset 4442
3485061166ca
parent 4441
88fcd0a1e58f
child 4448
a04937db5f68

A little fix in the download item for a situation causing a division by zero.

Helpviewer/Download/DownloadItem.py file | annotate | diff | comparison | revisions
--- a/Helpviewer/Download/DownloadItem.py	Tue Sep 08 18:54:07 2015 +0200
+++ b/Helpviewer/Download/DownloadItem.py	Tue Sep 08 18:56:13 2015 +0200
@@ -528,8 +528,11 @@
         if self.bytesTotal() == -1:
             return -1.0
         
-        timeRemaining = (self.bytesTotal() -
-                         self.bytesReceived()) / self.currentSpeed()
+        cSpeed = self.currentSpeed()
+        if cSpeed != 0:
+            timeRemaining = (self.bytesTotal() - self.bytesReceived()) / cSpeed
+        else:
+            timeRemaining = 1
         
         # ETA should never be 0
         if timeRemaining == 0:

eric ide

mercurial