]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Handle dangling symlinks in rmtree() and run_clean()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 29 Jul 2024 10:14:43 +0000 (12:14 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Mon, 29 Jul 2024 10:56:45 +0000 (12:56 +0200)
mkosi/__init__.py
mkosi/tree.py

index ae9a937140181b6aa7dd0e831d0df2d5b1d4e8ac..edc9784c6ea9b04263b303e8a12c00241472397b 100644 (file)
@@ -4587,7 +4587,7 @@ def run_clean(args: Args, config: Config, *, resources: Path) -> None:
         outputs = {
             config.output_dir_or_cwd() / output
             for output in config.outputs
-            if (config.output_dir_or_cwd() / output).exists()
+            if (config.output_dir_or_cwd() / output).exists() or (config.output_dir_or_cwd() / output).is_symlink()
         }
 
         # Make sure we resolve the symlink we create in the output directory and remove its target as well as it might
index 82154d8aace51c40553faee50aee96150cee3b91..f35bca1a163a0d366b6f081598a671e218c3bec2 100644 (file)
@@ -158,7 +158,7 @@ def rmtree(*paths: Path, sandbox: SandboxProtocol = nosandbox) -> None:
             stdout=subprocess.DEVNULL if not ARG_DEBUG.get() else None,
             stderr=subprocess.DEVNULL if not ARG_DEBUG.get() else None)
 
-    filtered = sorted({p for p in paths if p.exists()})
+    filtered = sorted({p for p in paths if p.exists() or p.is_symlink()})
     if filtered:
         run(["rm", "-rf", "--", *filtered],
             sandbox=sandbox(binary="rm", mounts=[Mount(p.parent, p.parent) for p in filtered]))