]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add missing directory checks in copy_tree()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 22 Aug 2024 13:46:06 +0000 (15:46 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 22 Aug 2024 14:49:50 +0000 (16:49 +0200)
mkosi/tree.py

index c2cf5ab86a785375fe43ca07be65c73f75aacef8..d2bf3003c5463d1c1bbcc3de48dd26f096d4f34c 100644 (file)
@@ -95,7 +95,7 @@ def copy_tree(
             src, dst,
         ]
 
-        if dst.exists() and any(dst.iterdir()) and cp_version(sandbox=sandbox) >= "9.5":
+        if dst.exists() and dst.is_dir() and any(dst.iterdir()) and cp_version(sandbox=sandbox) >= "9.5":
             cmdline += ["--keep-directory-symlink"]
 
         # If the source and destination are both directories, we want to merge the source directory with the
@@ -111,7 +111,7 @@ def copy_tree(
         use_subvolumes == ConfigFeature.disabled or
         not preserve or
         not is_subvolume(src) or
-        (dst.exists() and any(dst.iterdir()))
+        (dst.exists() and (not dst.is_dir() or any(dst.iterdir())))
     ):
         with (
             preserve_target_directories_stat(src, dst)