]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Only clean cache images if cache dir exists
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 15 May 2023 13:47:35 +0000 (15:47 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Mon, 15 May 2023 14:21:27 +0000 (16:21 +0200)
mkosi/__init__.py

index 867dea78e794ad1ea5ca48c9bd6275db4cf6d873..bf6da8328ba6834fe5c4eb383b936d0d191bad73 100644 (file)
@@ -1036,10 +1036,11 @@ def unlink_output(args: MkosiArgs, config: MkosiConfig) -> None:
                     unlink_try_hard(p)
 
     if remove_build_cache:
-        for p in cache_tree_paths(config):
-            if p.exists():
-                with complete_step(f"Removing cache entry {p}…"):
-                    unlink_try_hard(p)
+        if config.cache_dir:
+            for p in cache_tree_paths(config):
+                if p.exists():
+                    with complete_step(f"Removing cache entry {p}…"):
+                        unlink_try_hard(p)
 
         if config.build_dir and config.build_dir.exists() and any(config.build_dir.iterdir()):
             with complete_step("Clearing out build directory…"):