| Index: third_party/gsutil/third_party/apitools/apitools/base/py/transfer.py
|
| diff --git a/third_party/gsutil/third_party/apitools/apitools/base/py/transfer.py b/third_party/gsutil/third_party/apitools/apitools/base/py/transfer.py
|
| old mode 100755
|
| new mode 100644
|
| index 35a4774a6fb7cd49c40ad42bbfd89e5356147398..aba55ca966abf003d1f0c37f07576eff5d4ce7ca
|
| --- a/third_party/gsutil/third_party/apitools/apitools/base/py/transfer.py
|
| +++ b/third_party/gsutil/third_party/apitools/apitools/base/py/transfer.py
|
| @@ -331,7 +331,7 @@ class Download(_Transfer):
|
| else:
|
| if start < 0:
|
| start = max(0, start + self.total_size)
|
| - return start, self.total_size
|
| + return start, self.total_size - 1
|
|
|
| def __SetRangeHeader(self, request, start, end=None):
|
| if start < 0:
|
| @@ -364,12 +364,24 @@ class Download(_Transfer):
|
|
|
| """
|
| end_byte = end
|
| +
|
| + if start < 0 and not self.total_size:
|
| + return end_byte
|
| +
|
| if use_chunks:
|
| alternate = start + self.chunksize - 1
|
| - end_byte = min(end_byte, alternate) if end_byte else alternate
|
| + if end_byte is not None:
|
| + end_byte = min(end_byte, alternate)
|
| + else:
|
| + end_byte = alternate
|
| +
|
| if self.total_size:
|
| alternate = self.total_size - 1
|
| - end_byte = min(end_byte, alternate) if end_byte else alternate
|
| + if end_byte is not None:
|
| + end_byte = min(end_byte, alternate)
|
| + else:
|
| + end_byte = alternate
|
| +
|
| return end_byte
|
|
|
| def __GetChunk(self, start, end, additional_headers=None):
|
| @@ -434,22 +446,24 @@ class Download(_Transfer):
|
| self.EnsureInitialized()
|
| progress_end_normalized = False
|
| if self.total_size is not None:
|
| - progress, end = self.__NormalizeStartEnd(start, end)
|
| + progress, end_byte = self.__NormalizeStartEnd(start, end)
|
| progress_end_normalized = True
|
| else:
|
| progress = start
|
| - while not progress_end_normalized or progress < end:
|
| - end_byte = self.__ComputeEndByte(progress, end=end,
|
| + end_byte = end
|
| + while (not progress_end_normalized or end_byte is None or
|
| + progress <= end_byte):
|
| + end_byte = self.__ComputeEndByte(progress, end=end_byte,
|
| use_chunks=use_chunks)
|
| response = self.__GetChunk(progress, end_byte,
|
| additional_headers=additional_headers)
|
| if not progress_end_normalized:
|
| self.__SetTotal(response.info)
|
| - progress, end = self.__NormalizeStartEnd(start, end)
|
| + progress, end_byte = self.__NormalizeStartEnd(start, end)
|
| progress_end_normalized = True
|
| response = self.__ProcessResponse(response)
|
| progress += response.length
|
| - if not response:
|
| + if response.length == 0:
|
| raise exceptions.TransferRetryError(
|
| 'Zero bytes unexpectedly returned in download response')
|
|
|
| @@ -659,6 +673,8 @@ class Upload(_Transfer):
|
| Returns:
|
| None.
|
| """
|
| + if upload_config.resumable_path is None:
|
| + self.strategy = SIMPLE_UPLOAD
|
| if self.strategy is not None:
|
| return
|
| strategy = SIMPLE_UPLOAD
|
|
|