Skip to content

Commit

Permalink
Avoid incompleted download (#27)
Browse files Browse the repository at this point in the history
* compare file length

* avoid incomplete download

* avoid incomplete download
  • Loading branch information
liuchang0812 authored Mar 28, 2017
1 parent 627673e commit deee01a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions qcloud_cos/cos_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def __download_url(self, uri, filename):
if ret.status_code in [200, 206]:

if 'Content-Length' in ret.headers:
content_len = ret.headers['Content-Length']
content_len = int(ret.headers['Content-Length'])
else:
raise IOError("download failed without Content-Length header")

Expand All @@ -552,7 +552,7 @@ def __download_url(self, uri, filename):
if file_len != content_len:
raise IOError("download failed with incomplete file")
else:
raise IOError("download failed " + ret.text)
raise IOError("download failed with status code:" + str(ret.status_code))

def download_file(self, request):
assert isinstance(request, DownloadFileRequest)
Expand Down

0 comments on commit deee01a

Please sign in to comment.