]> git.ipfire.org Git - pbs.git/commitdiff
backend: Add function to create parent directories
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Oct 2022 14:17:13 +0000 (14:17 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Oct 2022 14:17:13 +0000 (14:17 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py

index c2b76f17a29252b9d4ec8849dfbe6365b5c7fe5f..52d01aa282376c5baafa29b14ed6e48136ea1956 100644 (file)
@@ -239,7 +239,17 @@ class Backend(object):
                """
                log.debug("Copying %s to %s" % (src, dst))
 
-               path = os.path.dirname(dst)
+               # Create parent directory
+               await self.make_parent_directory(dst)
+
+               # Copy data without any metadata
+               await asyncio.to_thread(shutil.copyfile, src, dst)
+
+       async def make_parent_directory(self, path):
+               """
+                       Creates the parent directory of path
+               """
+               path = os.path.dirname(path)
 
                # Create destination path (if it does not exist)
                try:
@@ -247,9 +257,6 @@ class Backend(object):
                except FileExistsError:
                        pass
 
-               # Copy data without any metadata
-               await asyncio.to_thread(shutil.copyfile, src, dst)
-
        async def unlink(self, path):
                """
                        Unlinks path