From 3c60f07d98abc10b8c6d736c59b39f4ae990f8cd Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 10 May 2018 15:29:35 -0700 Subject: [PATCH] Remove temporary files after run_compose A crash can also leave temporary lmc-* files, remove them as well. --- src/pylorax/api/queue.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pylorax/api/queue.py b/src/pylorax/api/queue.py index 664ea249..e943ccd5 100644 --- a/src/pylorax/api/queue.py +++ b/src/pylorax/api/queue.py @@ -209,7 +209,10 @@ def make_compose(cfg, results_dir): finally: # Make sure any remaining temporary directories are removed (eg. if there was an exception) for d in glob(joinpaths(cfg.tmp, "lmc-*")): - shutil.rmtree(d) + if os.path.isdir(d): + shutil.rmtree(d) + elif os.path.isfile(d): + os.unlink(d) # Make sure that everything under the results directory is owned by the user user = pwd.getpwuid(cfg.uid).pw_name