Don't worry with .seek if we're doing a fulldownload plan.

This commit is contained in:
Ethan Dalool 2020-09-25 15:37:09 -07:00
parent ade7d63231
commit 677d8a251f

View file

@ -81,8 +81,13 @@ def download_plan(plan):
if directory != '':
os.makedirs(directory, exist_ok=True)
touch(localname)
if plan['plan_type'] in ['resume', 'partial']:
file_handle = open(localname, 'r+b')
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:
plan['headers']['range'] = 'bytes={min}-{max}'.format(
@ -90,13 +95,6 @@ def download_plan(plan):
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(
'get',
plan['url'],