From 83651c408e37e917cc50fd3459bd868b5c563c39 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Wed, 4 Dec 2019 11:38:53 +0100 Subject: [PATCH] [IMP] runbot: keep txt files when cleaning builds dirs --- runbot/models/build.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index f95430dc..d593de38 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -533,10 +533,19 @@ class runbot_build(models.Model): dests = _filter(dest_list=os.listdir(builds_dir), label='workspace') for dest in dests: - path = os.path.join(builds_dir, dest) - if os.path.isdir(path) and os.path.isabs(path): - self._logger('Removing build directory') - shutil.rmtree(path) + build_dir = os.path.join(builds_dir, dest) + for f in os.listdir(build_dir): + path = os.path.join(build_dir, f) + if os.path.isdir(path) and f != 'logs': + shutil.rmtree(path) + elif f == 'logs': + log_path = os.path.join(build_dir, 'logs') + for f in os.listdir(log_path): + log_file_path = os.path.join(log_path, f) + if os.path.isdir(log_file_path): + shutil.rmtree(log_file_path) + elif not f.endswith('.txt'): + os.unlink(log_file_path) def _find_port(self): # currently used port