Only use Range when already have a partial download.

This commit is contained in:
Jakub Roztocil 2013-04-12 11:56:05 -03:00
parent e8d79c4d8c
commit d32acfe2fa

View File

@ -170,12 +170,8 @@ class Download(object):
# Disable content encoding so that we can resume, etc.
request_headers['Accept-Encoding'] = None
if self._resume:
try:
bytes_have = os.path.getsize(self._output_file.name)
except OSError as e:
if e.errno != errno.ENOENT:
raise
else:
bytes_have = os.path.getsize(self._output_file.name)
if bytes_have:
# Set ``Range`` header to resume the download
# TODO: Use "If-Range: mtime" to make sure it's fresh?
request_headers['Range'] = 'bytes=%d-' % bytes_have