From 5aec6e17461370421b41d23771a58af9a5e8333f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 16 Feb 2018 16:40:28 +0100 Subject: [PATCH] http: Create directory when a file should be downloaded to Signed-off-by: Michael Tremer --- src/pakfire/http.py | 5 +++++ 1 file changed, 5 insertions(+) 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) -- 2.39.5