Don't worry with .seek if we're doing a fulldownload plan.
This commit is contained in:
parent
ade7d63231
commit
677d8a251f
1 changed files with 7 additions and 9 deletions
|
@ -81,8 +81,13 @@ def download_plan(plan):
|
||||||
if directory != '':
|
if directory != '':
|
||||||
os.makedirs(directory, exist_ok=True)
|
os.makedirs(directory, exist_ok=True)
|
||||||
touch(localname)
|
touch(localname)
|
||||||
|
if plan['plan_type'] in ['resume', 'partial']:
|
||||||
file_handle = open(localname, 'r+b')
|
file_handle = open(localname, 'r+b')
|
||||||
file_handle.seek(plan['seek_to'])
|
file_handle.seek(plan['seek_to'])
|
||||||
|
bytes_downloaded = plan['seek_to']
|
||||||
|
elif plan['plan_type'] == 'fulldownload':
|
||||||
|
file_handle = open(localname, 'wb')
|
||||||
|
bytes_downloaded = 0
|
||||||
|
|
||||||
if plan['header_range_min'] is not None:
|
if plan['header_range_min'] is not None:
|
||||||
plan['headers']['range'] = 'bytes={min}-{max}'.format(
|
plan['headers']['range'] = 'bytes={min}-{max}'.format(
|
||||||
|
@ -90,13 +95,6 @@ def download_plan(plan):
|
||||||
max=plan['header_range_max'],
|
max=plan['header_range_max'],
|
||||||
)
|
)
|
||||||
|
|
||||||
if plan['plan_type'] == 'resume':
|
|
||||||
bytes_downloaded = plan['seek_to']
|
|
||||||
elif plan['plan_type'] == 'partial':
|
|
||||||
bytes_downloaded = plan['seek_to']
|
|
||||||
else:
|
|
||||||
bytes_downloaded = 0
|
|
||||||
|
|
||||||
download_stream = request(
|
download_stream = request(
|
||||||
'get',
|
'get',
|
||||||
plan['url'],
|
plan['url'],
|
||||||
|
|
Loading…
Reference in a new issue