From: c1541@hotmail.com <> Date: Wed, 7 Dec 2011 23:12:27 +0000 (+0100) Subject: Bug 684225: The removal of locally stored attachments should be done from Bugzilla... X-Git-Tag: bugzilla-4.3.1~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4badf488d539d7e50c7a156ecc65514796e6345a;p=thirdparty%2Fbugzilla.git Bug 684225: The removal of locally stored attachments should be done from Bugzilla::Attachment->remove_from_db r/a=LpSolit --- diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 3a8e7d5d5f..6c39818f69 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -900,6 +900,11 @@ sub remove_from_db { $dbh->do('UPDATE attachments SET mimetype = ?, ispatch = ?, isobsolete = ? WHERE attach_id = ?', undef, ('text/plain', 0, 1, $self->id)); $dbh->bz_commit_transaction(); + + my $filename = $self->_get_local_filename; + if (-e $filename) { + unlink $filename or warn "Couldn't unlink $filename: $!"; + } } ############################### diff --git a/attachment.cgi b/attachment.cgi index 35afc227ee..504ade424d 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -795,10 +795,6 @@ sub delete_attachment { # Paste the reason provided by the admin into a comment. $bug->add_comment($msg); - # If the attachment is stored locally, remove it. - if (-e $attachment->_get_local_filename) { - unlink $attachment->_get_local_filename; - } $attachment->remove_from_db(); # Now delete the token.