From 5730f43848cbfff178088d55205d03ce83ed5f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 15 Mar 2016 15:35:28 +0100 Subject: [PATCH] Allow downloading to non-existant directory --- blender_cloud/pillar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/blender_cloud/pillar.py b/blender_cloud/pillar.py index 0adbe5b..3210794 100644 --- a/blender_cloud/pillar.py +++ b/blender_cloud/pillar.py @@ -143,6 +143,8 @@ async def download_to_file(url, filename, chunk_size=100 * 1024, *, future: asyn # Download the file in a different thread. def download_loop(): + os.makedirs(os.path.dirname(filename), exist_ok=True) + with closing(req), open(filename, 'wb') as outfile: for block in req.iter_content(chunk_size=chunk_size): if is_cancelled(future):