]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make sure rmtree() doesn't fail on paths that don't exist
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Jul 2024 10:16:40 +0000 (12:16 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Jul 2024 10:16:40 +0000 (12:16 +0200)
mkosi/tree.py

index 13ddb54cc20a927bd29aae33dc8c60ae4b2e33c1..94adc66c3e1522bc8f324294ecf879b38c628685 100644 (file)
@@ -149,7 +149,7 @@ def rmtree(*paths: Path, sandbox: SandboxProtocol = nosandbox) -> None:
     if not paths:
         return
 
-    if subvolumes := sorted({p for p in paths if is_subvolume(p, sandbox=sandbox)}):
+    if subvolumes := sorted({p for p in paths if p.exists() and is_subvolume(p, sandbox=sandbox)}):
         # Silence and ignore failures since when not running as root, this will fail with a permission error unless the
         # btrfs filesystem is mounted with user_subvol_rm_allowed.
         run(["btrfs", "subvolume", "delete", *subvolumes],