Skip to content

Commit

Permalink
[FIX] runbot: dont duplicate export
Browse files Browse the repository at this point in the history
Even if it isn't really problematic, avoiding to duplicate exports
will make the table slighly smaller, especially when considering running
builds.
  • Loading branch information
Xavier-Do committed Mar 16, 2022
1 parent 3985332 commit c4d0b56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions runbot/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ def write(self, values):
build_by_old_values = defaultdict(lambda: self.env['runbot.build'])
for record in self:
build_by_old_values[record.local_state] += record
if values['local_state'] == 'done':
self.env['runbot.commit.export'].search([('build_id', 'in', self.ids)]).unlink()
local_result = values.get('local_result')
for build in self:
if local_result and local_result != self._get_worst_result([build.local_result, local_result]): # dont write ok on a warn/error build
Expand Down Expand Up @@ -729,8 +731,6 @@ def _schedule(self):
build._github_status()
build._run_job()

if build.local_state == 'done':
self.env['runbot.commit.export'].search([('build_id', '=', build.id)]).unlink()

def _run_job(self):
# run job
Expand Down
3 changes: 2 additions & 1 deletion runbot/models/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def export(self, build):
"""Export a git repo into a sources"""
# TODO add automated tests
self.ensure_one()
self.env['runbot.commit.export'].create({'commit_id': self.id, 'build_id': build.id})
if not self.env['runbot.commit.export'].search([('build_id', '=', build.id), ('commit_id', '=', self.id)]):
self.env['runbot.commit.export'].create({'commit_id': self.id, 'build_id': build.id})
export_path = self._source_path()

if os.path.isdir(export_path):
Expand Down

0 comments on commit c4d0b56

Please sign in to comment.