Allow downloading to non-existant directory
This commit is contained in:
parent
7520421083
commit
5730f43848
@ -143,6 +143,8 @@ async def download_to_file(url, filename, chunk_size=100 * 1024, *, future: asyn
|
|||||||
|
|
||||||
# Download the file in a different thread.
|
# Download the file in a different thread.
|
||||||
def download_loop():
|
def download_loop():
|
||||||
|
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
||||||
|
|
||||||
with closing(req), open(filename, 'wb') as outfile:
|
with closing(req), open(filename, 'wb') as outfile:
|
||||||
for block in req.iter_content(chunk_size=chunk_size):
|
for block in req.iter_content(chunk_size=chunk_size):
|
||||||
if is_cancelled(future):
|
if is_cancelled(future):
|
||||||
|
Reference in New Issue
Block a user