diff --git a/voussoirkit/downloady.py b/voussoirkit/downloady.py index 1ad347f..e59b6bf 100644 --- a/voussoirkit/downloady.py +++ b/voussoirkit/downloady.py @@ -81,8 +81,13 @@ def download_plan(plan): if directory != '': os.makedirs(directory, exist_ok=True) touch(localname) - file_handle = open(localname, 'r+b') - file_handle.seek(plan['seek_to']) + 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'],