[Rt-commit] r7891 - rt/branches/3.6-RELEASE/lib/RT/Interface

ruz at bestpractical.com ruz at bestpractical.com
Wed May 16 21:31:36 EDT 2007


Author: ruz
Date: Wed May 16 21:31:35 2007
New Revision: 7891

Modified:
   rt/branches/3.6-RELEASE/lib/RT/Interface/Web.pm

Log:
* revert jesse's patch that slurps uploads into session,
  this may hurt badly with multiple attachments.

Modified: rt/branches/3.6-RELEASE/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT/Interface/Web.pm	(original)
+++ rt/branches/3.6-RELEASE/lib/RT/Interface/Web.pm	Wed May 16 21:31:35 2007
@@ -636,9 +636,25 @@
 
     if (my $filehandle = $cgi_object->upload( $args{'AttachmentFieldName'} ) ) {
 
-    my (@content,$buffer);
+
+
+    use File::Temp qw(tempfile tempdir);
+
+    #foreach my $filehandle (@filenames) {
+
+    my ( $fh, $temp_file );
+    for ( 1 .. 10 ) {
+        # on NFS and NTFS, it is possible that tempfile() conflicts
+        # with other processes, causing a race condition. we try to
+        # accommodate this by pausing and retrying.
+        last if ($fh, $temp_file) = eval { tempfile( UNLINK => 1) };
+        sleep 1;
+    }
+
+    binmode $fh;    #thank you, windows
+    my ($buffer);
     while ( my $bytesread = read( $filehandle, $buffer, 4096 ) ) {
-        push @content, $buffer;
+        print $fh $buffer;
     }
 
     my $uploadinfo = $cgi_object->uploadInfo($filehandle);
@@ -649,13 +665,12 @@
                    
     $filename =~ s#^.*[\\/]##;
 
-
-    
     $Message->attach(
-        Data    => \@content,
+        Path     => $temp_file,
         Filename => Encode::decode_utf8($filename),
         Type     => $uploadinfo->{'Content-Type'},
     );
+    close($fh);
 
     #   }
 


More information about the Rt-commit mailing list