]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
sandbox: Only create parent directories if dst does not exist yet 3196/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 15 Nov 2024 11:05:53 +0000 (12:05 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 15 Nov 2024 11:05:53 +0000 (12:05 +0100)
mkosi/sandbox.py

index 47ea56493319afbc83b9cf387ec8e25e5124ac6b..0cb86378eabdc8e3e41c56c20c06da0771f5f3cd 100755 (executable)
@@ -464,12 +464,12 @@ class BindOperation(FSOperation):
         if not os.path.exists(src) and not self.required:
             return
 
-        with umask(~0o755):
-            os.makedirs(os.path.dirname(dst), exist_ok=True)
-
         if not os.path.exists(dst):
             isfile = os.path.isfile(src)
 
+            with umask(~0o755):
+                os.makedirs(os.path.dirname(dst), exist_ok=True)
+
             with umask(~0o644 if isfile else ~0o755):
                 if isfile:
                     os.close(os.open(dst, os.O_CREAT | os.O_CLOEXEC | os.O_EXCL))