From 6a570a0ce38f41f8aad67d92d05331a036380bbe Mon Sep 17 00:00:00 2001 From: PythonNut Date: Fri, 6 May 2016 05:25:14 +0000 Subject: [PATCH] Fix I/O error when creating empty file httplib 0.9.2 raises an exception when determining the progress of a zero-length transaction --- gdrivefs/gdtool/drive.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gdrivefs/gdtool/drive.py b/gdrivefs/gdtool/drive.py index f328455..b24419a 100644 --- a/gdrivefs/gdtool/drive.py +++ b/gdrivefs/gdtool/drive.py @@ -458,13 +458,16 @@ def download_to_local(self, output_file_path, normalized_entry, mime_type, _logger.debug("Read chunk: STATUS=[%s] DONE=[%s] " "TOTAL_SIZE=[%s]", status, done, total_size) - p = status.progress() + if status.total_size > 0: + percent = status.progress() + else: + percent = 100.0 _logger.debug("Chunk: PROGRESS=[%s] TOTAL-SIZE=[%s] " "RESUMABLE-PROGRESS=[%s]", - p, status.total_size, status.resumable_progress) + percent, status.total_size, + status.resumable_progress) - percent = p if status.total_size > 0 else 100.0 # TODO(dustin): This just places an arbitrary limit on the number of empty # chunks we can receive. Can we drop this to 1? if len(progresses) >= _MAX_EMPTY_CHUNKS: