#11672 closed defect (fixed)
Deleting a milestone should delete its attachments — at Version 4
Reported by: | Peter Suter | Owned by: | Peter Suter |
---|---|---|---|
Priority: | normal | Milestone: | 0.12.6 |
Component: | roadmap | Version: | 0.12.5 |
Severity: | normal | Keywords: | attachment delete milestone |
Cc: | Branch: | ||
Release Notes: |
Deleting a milestone now also deletes its attachments. |
||
API Changes: |
|
||
Internal Changes: |
Description (last modified by )
Deleting a milestone does not delete its attachments. (As previously discussed.)
Proposed fix:
-
trac/ticket/model.py
diff -r 19ce84254a0a trac/ticket/model.py
a b 1011 1011 with self.env.db_transaction as db: 1012 1012 self.env.log.info("Deleting milestone %s", self.name) 1013 1013 db("DELETE FROM milestone WHERE name=%s", (self.name,)) 1014 Attachment.delete_all(self.env, self.realm, self.name) 1014 1015 # Don't translate ticket comment (comment:40:ticket:5658) 1015 1016 self.move_tickets(retarget_to, author, "Milestone deleted") 1016 1017 self._old['name'] = None
Reparenting of attachments when a milestone is renamed was previously fixed in #7933 and a unit test was added.
A similar unit test should be added for deleting attachments.
Change History (5)
comment:1 by , 10 years ago
Description: | modified (diff) |
---|
by , 10 years ago
Attachment: | T11672-delete-milestone-attachments.diff added |
---|
comment:2 by , 10 years ago
Description: | modified (diff) |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:3 by , 10 years ago
Looks good to me. At first I thought this would just leave stray files on the filesystem, but another consequence is that attachments reappear if the milestone is deleted and recreated with the same name.
In the attached patch I rebased the proposed fix for 0.12.6 and added a unit test.