Fix possible division by zero crash

This commit is contained in:
Andrew Resch 2008-07-15 06:54:44 +00:00
parent c1622b23aa
commit 1209663595

View File

@ -371,7 +371,10 @@ class Torrent:
file_progress = self.handle.file_progress()
ret = []
for i,f in enumerate(self.files):
ret.append(float(file_progress[i]) / float(f["size"]))
try:
ret.append(float(file_progress[i]) / float(f["size"]))
except ZeroDivisionError:
ret.append(0.0)
return ret