mirror of
https://github.com/timsutton/brigadier.git
synced 2025-06-06 17:51:22 -04:00
Update downloader.py
This commit is contained in:
parent
1212a277be
commit
a8d00cc4dc
1 changed files with 2 additions and 2 deletions
|
@ -264,7 +264,7 @@ class Downloader:
|
||||||
process.join()
|
process.join()
|
||||||
return chunk_so_far
|
return chunk_so_far
|
||||||
|
|
||||||
def stream_to_file(self, url, file_path, progress = True, headers = None, ensure_size_if_present = True):
|
def stream_to_file(self, url, file_path, progress = True, headers = None, ensure_size_if_present = True, allow_resume = True):
|
||||||
response = self.open_url(url, headers)
|
response = self.open_url(url, headers)
|
||||||
if response is None: return None
|
if response is None: return None
|
||||||
bytes_so_far = 0
|
bytes_so_far = 0
|
||||||
|
@ -272,7 +272,7 @@ class Downloader:
|
||||||
except: total_size = -1
|
except: total_size = -1
|
||||||
packets = queue = process = None
|
packets = queue = process = None
|
||||||
mode = "wb"
|
mode = "wb"
|
||||||
if os.path.isfile(file_path) and total_size != -1:
|
if allow_resume and os.path.isfile(file_path) and total_size != -1:
|
||||||
# File exists, we're resuming and have a target size. Check the
|
# File exists, we're resuming and have a target size. Check the
|
||||||
# local file size.
|
# local file size.
|
||||||
current_size = os.stat(file_path).st_size
|
current_size = os.stat(file_path).st_size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue