From: Daan De Meyer Date: Wed, 3 Jan 2024 13:43:41 +0000 (+0100) Subject: tree: Simplify copy_tree() a little X-Git-Tag: v20~17^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=256589632c48f13ae91d2fe45bbd230787744593;p=thirdparty%2Fmkosi.git tree: Simplify copy_tree() a little --- diff --git a/mkosi/tree.py b/mkosi/tree.py index 43b84358d..6eaaeac97 100644 --- a/mkosi/tree.py +++ b/mkosi/tree.py @@ -88,7 +88,13 @@ def copy_tree( copy += ["--no-target-directory"] # Subvolumes always have inode 256 so we can use that to check if a directory is a subvolume. - if not subvolume or not preserve_owner or not is_subvolume(src) or (dst.exists() and any(dst.iterdir())): + if ( + not subvolume or + not preserve_owner or + not is_subvolume(src) or + not shutil.which("btrfs") or + (dst.exists() and any(dst.iterdir())) + ): with ( preserve_target_directories_stat(src, dst) if not preserve_owner @@ -101,12 +107,8 @@ def copy_tree( if dst.exists(): dst.rmdir() - if shutil.which("btrfs"): - result = run(["btrfs", "subvolume", "snapshot", src, dst], - check=use_subvolumes == ConfigFeature.enabled).returncode - else: - result = 1 - + result = run(["btrfs", "subvolume", "snapshot", src, dst], + check=use_subvolumes == ConfigFeature.enabled).returncode if result != 0: with ( preserve_target_directories_stat(src, dst)