]> git.ipfire.org Git - pakfire.git/commitdiff
http: Create directory when a file should be downloaded to
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Feb 2018 15:40:28 +0000 (16:40 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Feb 2018 15:40:28 +0000 (16:40 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/http.py

index 39fa1336d2ce31484cdea80f05fc6399e42d3b7c..1c4429b9017a29c50403731914311f95bb7d65cd 100644 (file)
@@ -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)