mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[REF] runbot: Consider empty returned values
When installing a clean runbot instance a bad query is made because there is not any build yet. With this commmit, the query is not made when there are no builds directories found on the filesystem.
This commit is contained in:
parent
dcdd16038b
commit
c9de61a320
@ -307,18 +307,19 @@ class runbot_build(models.Model):
|
||||
root = self.env['runbot.repo']._root()
|
||||
build_dir = os.path.join(root, 'build')
|
||||
builds = os.listdir(build_dir)
|
||||
self.env.cr.execute("""
|
||||
SELECT dest
|
||||
FROM runbot_build
|
||||
WHERE dest IN %s
|
||||
AND (state != 'done' OR job_end > (now() - interval '7 days'))
|
||||
""", [tuple(builds)])
|
||||
actives = set(b[0] for b in self.env.cr.fetchall())
|
||||
if builds:
|
||||
self.env.cr.execute("""
|
||||
SELECT dest
|
||||
FROM runbot_build
|
||||
WHERE dest IN %s
|
||||
AND (state != 'done' OR job_end > (now() - interval '7 days'))
|
||||
""", [tuple(builds)])
|
||||
actives = set(b[0] for b in self.env.cr.fetchall())
|
||||
|
||||
for b in builds:
|
||||
path = os.path.join(build_dir, b)
|
||||
if b not in actives and os.path.isdir(path) and os.path.isabs(path):
|
||||
shutil.rmtree(path)
|
||||
for b in builds:
|
||||
path = os.path.join(build_dir, b)
|
||||
if b not in actives and os.path.isdir(path) and os.path.isabs(path):
|
||||
shutil.rmtree(path)
|
||||
|
||||
# cleanup old unused databases
|
||||
self.env.cr.execute("select id from runbot_build where state in ('testing', 'running')")
|
||||
|
Loading…
Reference in New Issue
Block a user