mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot: better source cleaing
A build can sometimes fail and be stuck in a running state without corresponding sources. In this case, source are not gc anymore This commit fixes that by always applying gc even when an inconsistency is detected.
This commit is contained in:
parent
9e5ee700f3
commit
6681e40231
@ -647,17 +647,16 @@ class runbot_repo(models.Model):
|
||||
# we are comparing cannot_be_deleted_path with to keep to sensure that the algorithm is working, we want to avoid to erase file by mistake
|
||||
# note: it is possible that a parent_build is in testing without checkouting sources, but it should be exceptions
|
||||
if to_delete:
|
||||
if cannot_be_deleted_path == to_keep:
|
||||
to_delete = list(to_delete)
|
||||
to_keep = list(to_keep)
|
||||
cannot_be_deleted_path = list(cannot_be_deleted_path)
|
||||
for source_dir in to_delete:
|
||||
_logger.info('Deleting source: %s' % source_dir)
|
||||
assert 'static' in source_dir
|
||||
shutil.rmtree(source_dir)
|
||||
_logger.info('%s/%s source folder where deleted (%s kept)' % (len(to_delete), len(to_delete+to_keep), len(to_keep)))
|
||||
else:
|
||||
if cannot_be_deleted_path != to_keep:
|
||||
_logger.warning('Inconsistency between sources and database: \n%s \n%s' % (cannot_be_deleted_path-to_keep, to_keep-cannot_be_deleted_path))
|
||||
to_delete = list(to_delete)
|
||||
to_keep = list(to_keep)
|
||||
cannot_be_deleted_path = list(cannot_be_deleted_path)
|
||||
for source_dir in to_delete:
|
||||
_logger.info('Deleting source: %s' % source_dir)
|
||||
assert 'static' in source_dir
|
||||
shutil.rmtree(source_dir)
|
||||
_logger.info('%s/%s source folder where deleted (%s kept)' % (len(to_delete), len(to_delete+to_keep), len(to_keep)))
|
||||
|
||||
except:
|
||||
_logger.error('An exception occured while cleaning sources')
|
||||
|
Loading…
Reference in New Issue
Block a user