From: Michael Tremer Date: Fri, 16 Feb 2018 15:40:28 +0000 (+0100) Subject: http: Create directory when a file should be downloaded to X-Git-Tag: 0.9.28~1285^2~1116 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5aec6e17461370421b41d23771a58af9a5e8333f;p=pakfire.git http: Create directory when a file should be downloaded to Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/http.py b/src/pakfire/http.py index 39fa1336d..1c4429b90 100644 --- a/src/pakfire/http.py +++ b/src/pakfire/http.py @@ -383,6 +383,11 @@ class Client(object): # Otherwise raise this error raise e + # Make sure parent directory exists + dirname = os.path.dirname(filename) + if not os.path.exists(dirname): + os.makedirs(dirname) + # Downloaded succeeded, writing data to filesystem with open(filename, "wb") as output: shutil.copyfileobj(f, output)