r27509 - in /branches/upstream/libmail-imapclient-perl/current: Changes META.yml lib/Mail/IMAPClient.pm

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Sun Nov 30 17:08:40 UTC 2008


Author: ansgar-guest
Date: Sun Nov 30 17:08:37 2008
New Revision: 27509

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=27509
Log:
[svn-upgrade] Integrating new upstream version, libmail-imapclient-perl (3.12)

Modified:
    branches/upstream/libmail-imapclient-perl/current/Changes
    branches/upstream/libmail-imapclient-perl/current/META.yml
    branches/upstream/libmail-imapclient-perl/current/lib/Mail/IMAPClient.pm

Modified: branches/upstream/libmail-imapclient-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmail-imapclient-perl/current/Changes?rev=27509&op=diff
==============================================================================
--- branches/upstream/libmail-imapclient-perl/current/Changes (original)
+++ branches/upstream/libmail-imapclient-perl/current/Changes Sun Nov 30 17:08:37 2008
@@ -2,6 +2,14 @@
 == Revision History for Mail::IMAPClient
 All changes from 2.99_01 upward are made by Mark Overmeer.  The changes
 before that are applied by David Kernen
+
+version 3.12: Mon Nov 24 15:34:58 CET 2008
+
+	Improvement:
+
+	- major performance improvement in append_message(), avoiding
+	  reading the whole file in memory as the docs promised but the
+	  code didn't do.  [David Podolsky]
 
 version 3.11: Wed Oct  8 10:57:31 CEST 2008
 

Modified: branches/upstream/libmail-imapclient-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmail-imapclient-perl/current/META.yml?rev=27509&op=diff
==============================================================================
--- branches/upstream/libmail-imapclient-perl/current/META.yml (original)
+++ branches/upstream/libmail-imapclient-perl/current/META.yml Sun Nov 30 17:08:37 2008
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Mail-IMAPClient
-version:             3.11
+version:             3.12
 abstract:            IMAP4 client library
 license:             ~
 author:              ~

Modified: branches/upstream/libmail-imapclient-perl/current/lib/Mail/IMAPClient.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmail-imapclient-perl/current/lib/Mail/IMAPClient.pm?rev=27509&op=diff
==============================================================================
--- branches/upstream/libmail-imapclient-perl/current/lib/Mail/IMAPClient.pm (original)
+++ branches/upstream/libmail-imapclient-perl/current/lib/Mail/IMAPClient.pm Sun Nov 30 17:08:37 2008
@@ -2,7 +2,7 @@
 use strict;
 
 package Mail::IMAPClient;
-our $VERSION = '3.11';
+our $VERSION = '3.12';
 
 use Mail::IMAPClient::MessageSet;
 
@@ -21,15 +21,20 @@
 use MIME::Base64;
 use File::Spec  ();
 
-use constant Unconnected   => 0;
-use constant Connected     => 1; # connected; not logged in
-use constant Authenticated => 2; # logged in; no mailbox selected
-use constant Selected      => 3; # mailbox selected
-
-use constant INDEX         => 0; # Array index for output line number
-use constant TYPE          => 1; # Array index for line type
-                                 #    (either OUTPUT, INPUT, or LITERAL)
-use constant DATA          => 2; # Array index for output line data
+use constant APPEND_BUFFER_SIZE => 1024 * 1024;
+
+use constant
+  { Unconnected   => 0
+  , Connected     => 1 # connected; not logged in
+  , Authenticated => 2 # logged in; no mailbox selected
+  , Selected      => 3 # mailbox selected
+  };
+
+use constant
+  { INDEX         => 0 # Array index for output line number
+  , TYPE          => 1 # Array index for line type (OUTPUT, INPUT, or LITERAL)
+  , DATA          => 2 # Array index for output line data
+  };
 
 use constant NonFolderArg => 1;  # Value to pass to Massage to
                                  #    indicate non-folder argument
@@ -2382,7 +2387,7 @@
         return undef;
     }
 
-    my $fh = IO::File->new($file);
+    my $fh = IO::File->new($file, 'rb');
     unless($fh)
     {   $self->LastError("Unable to open $file: $!");
         return undef;
@@ -2394,7 +2399,10 @@
         $date = qq{"$f" };
     }
 
-    my $bare_nl_count = grep m/^\n$|[^\r]\n$/, <$fh>;
+    my $bare_nl_count = 0;
+    while(<$fh>)                 # do no read the whole file at once!
+    {   $bare_nl_count++ if m/^\n$|[^\r]\n$/;
+    }
 
     seek($fh,0,0);
 
@@ -2438,38 +2446,23 @@
         }
     }
 
-    # Slurp up headers: later we'll make this more efficient I guess
-
-    local $/ = "\r\n\r\n";
-    my $text = <$fh>;
-
-    $text =~ s/\r?\n/\r\n/g;
-    $self->_record($count, [$self->_next_index($count),"INPUT","{From $file}"]);
-
-    unless($self->_send_line($text))
-    {   $self->LastError("Error sending append msg text to IMAP: $!");
-        $fh->close;
-        return undef;
-    }
-    $self->_debug("control points to $$control\n") if ref $control;
-
-    $/ = ref $control ? "\n" : $control ? $control : "\n";
-    while(defined($text = <$fh>))
-    {   $text =~ s/\r?\n/\r\n/g;
-        $self->_record($count,
-            [ $self->_next_index($count), "INPUT", "{from $file}"]);
-
-        unless($self->_send_line($text,1))
-        {   $self->LastError("Error sending append msg text to IMAP: $!");
-            $fh->close;
-            return undef;
-        }
-    }
-
-    unless($self->_send_line("\r\n"))
-    {   $self->LastError("Error sending append msg text to IMAP: $!");
-        $fh->close;
-        return undef;
+    # Now send the message itself
+    local $/ = ref $control ? "\n" : $control ? $control : "\n";
+    my $buffer;
+
+    while($fh->sysread($buffer, APPEND_BUFFER_SIZE))
+    {    $buffer =~ s/\A\n/\r\n/;
+         $buffer =~ s/(?<![^\r])\n/\r\n/g;
+
+         $self->_record( $count, [ $self->_next_index($count), "INPUT"
+                                 , '{'.length($buffer)." bytes from $file}" ] );
+
+         my $bytes_written = $self->_send_line($buffer, 1);
+         unless($bytes_written)
+         {    $self->LastError("Error sending append msg text to IMAP: $!");
+              $fh->close;
+              return undef;
+         }
     }
 
     # Now for the crucial test: Did the append work or not?




More information about the Pkg-perl-cvs-commits mailing list