From d609f55d987a2a75e44726589b99957483575f0d Mon Sep 17 00:00:00 2001 From: DaanDeMeyer Date: Thu, 3 Jul 2025 13:45:22 +0200 Subject: [PATCH] Fix /var/tmp directory cleanup Currently, if /work does not exist, we go into the exception handler which doesn't do anything if the errno is ENOENT, even though we still need to remove the parent directory. --- mkosi/run.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mkosi/run.py b/mkosi/run.py index 97c685ad8..d41cc5ed0 100644 --- a/mkosi/run.py +++ b/mkosi/run.py @@ -444,7 +444,8 @@ def vartmpdir() -> Iterator[Path]: # the subdirectory when it is empty is not a problem because deleting a subdirectory depends on the # permissions of the parent directory and not the directory itself. try: - (d / "work").rmdir() + if (p := d / "work").exists(): + p.rmdir() except OSError as e: if e.errno == errno.ENOTEMPTY: @@ -453,7 +454,7 @@ def vartmpdir() -> Iterator[Path]: shutil.rmtree(d) fork_and_wait(remove) - elif e.errno != errno.ENOENT: + else: raise else: shutil.rmtree(d) -- 2.47.3