Skip to content

Commit

Permalink
Merge pull request #156 from MilhouseVH/le10_fix_divbyzero
Browse files Browse the repository at this point in the history
Fix potential divide by zero errors
  • Loading branch information
CvH committed Apr 18, 2020
2 parents 79b65a5 + 9661fbe commit 06203d4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/oe.py
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 06203d4

Please sign in to comment.