]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 684225: The removal of locally stored attachments should be done from Bugzilla...
authorc1541@hotmail.com <>
Wed, 7 Dec 2011 23:12:27 +0000 (00:12 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Wed, 7 Dec 2011 23:12:27 +0000 (00:12 +0100)
r/a=LpSolit

Bugzilla/Attachment.pm
attachment.cgi

index 3a8e7d5d5ffdb7bae02f181f42fb3ab6a96b8bfe..6c39818f69c9e8ded8fd01160bfe1975c41b0708 100644 (file)
@@ -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: $!";
+    }
 }
 
 ###############################
index 35afc227eee0a188aa40d694022d6e90822cf660..504ade424d1b2f953380588b1a9698b3cbb083ae 100755 (executable)
@@ -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.