Skip to content

Commit 8b531ad

Browse files
committed
Fixed divide-by-zero on progress.
1 parent 0530dc1 commit 8b531ad

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

gdrivefs/gdtool/drive.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,16 @@ def download_to_local(self, output_file_path, normalized_entry, mime_type,
458458
_logger.debug("Read chunk: STATUS=[%s] DONE=[%s] "
459459
"TOTAL_SIZE=[%s]", status, done, total_size)
460460

461-
p = status.progress()
461+
if status.total_size > 0:
462+
percent = status.progress()
463+
else:
464+
percent = 100.0
462465

463466
_logger.debug("Chunk: PROGRESS=[%s] TOTAL-SIZE=[%s] "
464467
"RESUMABLE-PROGRESS=[%s]",
465-
p, status.total_size, status.resumable_progress)
468+
percent, status.total_size,
469+
status.resumable_progress)
466470

467-
percent = p if status.total_size > 0 else 100.0
468471
# TODO(dustin): This just places an arbitrary limit on the number of empty
469472
# chunks we can receive. Can we drop this to 1?
470473
if len(progresses) >= _MAX_EMPTY_CHUNKS:

0 commit comments

Comments
 (0)