[Rt-commit] rt branch, 4.0/clean-rest-tmp-files, created. rt-4.0.10rc1-1-g37d5563

? sunnavy sunnavy at bestpractical.com
Tue Jan 29 12:19:36 EST 2013


The branch, 4.0/clean-rest-tmp-files has been created
        at  37d5563e4fdc27649c0f252c5f7e245403273456 (commit)

- Log -----------------------------------------------------------------
commit 37d5563e4fdc27649c0f252c5f7e245403273456
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jan 30 01:03:51 2013 +0800

    clean up tmp files in REST
    
    the reason that we unlink those files quite late is the MIME::Entity
    object($ent) still makes use of them.

diff --git a/share/html/REST/1.0/Forms/ticket/comment b/share/html/REST/1.0/Forms/ticket/comment
index d511c46..b50135f 100644
--- a/share/html/REST/1.0/Forms/ticket/comment
+++ b/share/html/REST/1.0/Forms/ticket/comment
@@ -56,6 +56,7 @@ use MIME::Entity;
 use LWP::MediaTypes;
 use RT::Interface::REST;
 use File::Temp qw(tempfile);
+my @tmp_files;
 
 $RT::Logger->debug("Got ticket id=$id for comment");
 $RT::Logger->debug("Got args @{[keys(%changes)]}.");
@@ -106,6 +107,7 @@ foreach my $att (@atts) {
         my $buf;
         my ($w, $tmp) = tempfile();
         my $info = $cgi->uploadInfo($fh);
+        push @tmp_files, $tmp;
 
         while (sysread($fh, $buf, 8192)) {
             syswrite($w, $buf);
@@ -151,5 +153,7 @@ if ($changes{Status}) {
 }
 
 OUTPUT:
+
+unlink @tmp_files;
 return [ $c, $o, $k, $e ];
 </%INIT>
diff --git a/share/html/REST/1.0/ticket/comment b/share/html/REST/1.0/ticket/comment
index 23397df..475e3a8 100644
--- a/share/html/REST/1.0/ticket/comment
+++ b/share/html/REST/1.0/ticket/comment
@@ -55,6 +55,7 @@ use MIME::Entity;
 use LWP::MediaTypes;
 use RT::Interface::REST;
 use File::Temp qw(tempfile);
+my @tmp_files;
 
 my $ticket = RT::Ticket->new($session{CurrentUser});
 my $object = $r->path_info;
@@ -122,6 +123,7 @@ foreach my $att (@atts) {
     if ($fh) {
         my $buf;
         my ($w, $tmp) = tempfile();
+        push @tmp_files, $tmp;
         my $info = $cgi->uploadInfo();
 
         while (sysread($fh, $buf, 8192)) {
@@ -174,6 +176,8 @@ if ($k->{Status}) {
 }
 
 OUTPUT:
+
+unlink @tmp_files;
 </%INIT>
 RT/<% $RT::VERSION %> <% $status %>
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list