# HG changeset patch # User wbell # Date 1271900785 0 # Node ID 91aabd647610f222bd5ad3fb26970aa03a0a5f42 # Parent 0bec85f087e6809d53da0c2b466cf7e7f50aced8 Delete attachments when builds are cancelled/invalidated. These methods should all be pulled together at some point. diff --git a/bitten/master.py b/bitten/master.py --- a/bitten/master.py +++ b/bitten/master.py @@ -210,6 +210,9 @@ for step in list(BuildStep.select(self.env, build=build.id, db=db)): step.delete(db=db) build.update(db=db) + + Attachment.delete_all(self.env, 'build', build.resource.id, db) + db.commit() for listener in BuildSystem(self.env).listeners: @@ -330,6 +333,7 @@ filename = attach_elem.attr.get('filename') resource_id = attach_elem.attr.get('resource') == 'config' \ and build.config or build.resource.id + try: # Delete attachment if it already exists old_attach = Attachment(self.env, 'build', parent_id=resource_id, filename=filename) diff --git a/bitten/queue.py b/bitten/queue.py --- a/bitten/queue.py +++ b/bitten/queue.py @@ -24,6 +24,8 @@ import time from trac.util.datefmt import to_timestamp +from trac.attachment import Attachment + from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep @@ -287,6 +289,8 @@ for step in list(BuildStep.select(self.env, build=build.id, db=db)): step.delete(db=db) build.update(db=db) + + Attachment.delete_all(self.env, 'build', build.resource.id, db) db.commit() def should_delete_build(self, build, repos): diff --git a/bitten/web_ui.py b/bitten/web_ui.py --- a/bitten/web_ui.py +++ b/bitten/web_ui.py @@ -16,7 +16,7 @@ import pkg_resources from genshi.builder import tag -from trac.attachment import AttachmentModule +from trac.attachment import AttachmentModule, Attachment from trac.core import * from trac.mimeview.api import Context from trac.resource import Resource @@ -650,6 +650,8 @@ build.slave_info = {} build.update() + Attachment.delete_all(self.env, 'build', build.resource.id, db) + db.commit() req.redirect(req.href.build(build.config))