Skip to content

Commit

Permalink
Fix potential divide by zero errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MilhouseVH committed Apr 13, 2020
1 parent 79b65a5 commit 9661fbe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/oe.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,15 @@ def sample(self, chunk):
self.start = now

if (now - self.start) >= self.minSampleInterval or not chunk:
self.speed = int((self.partial_size - self.prev_size) / (now - self.start) / 1024)
self.speed = max(int((self.partial_size - self.prev_size) / (now - self.start) / 1024), 1)
remain = self.total_size - self.partial_size
self.minutes = int(remain / 1024 / self.speed / 60)
self.seconds = int(remain / 1024 / self.speed) % 60
self.prev_size = self.partial_size
self.start = now

self.percent = int(self.partial_size * 100.0 / self.total_size)
if self.total_size != 0:
self.percent = int(self.partial_size * 100.0 / self.total_size)

# Update the progress dialog when required, or upon completion
def needsUpdate(self, chunk):
Expand Down

0 comments on commit 9661fbe

Please sign in to comment.