[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[imapsync] patch for 1.267: add --allowsizemismatch and log error when fetch message fails
|
From |
Phil Lobbes <plobbes at zimbra dot com> |
|
Subject |
[imapsync] patch for 1.267: add --allowsizemismatch and log error when fetch message fails |
|
Date |
Tue, 3 Feb 2009 18:18:23 -0800 (PST) |
Hi everyone,
Attached is a patch to 1.267 to add a new option '--allowsizemismatch' to imapsync. This requires Mail::IMAPClient v3.x. This can be useful when using imapsync against a (buggy?) IMAP server where RFC822.size does not always match the fetched message size. Typically, you would use the '--skipsize' with this option to avoid having a messages synced more than once if you're running imapsync in multiple passes on mailboxes.
In addition, this patch catches a case where if $from->message_string returned undef but imapsync ignored this and tried to APPEND an empty message to the "$to" server. Now, the error count is incremented and a warning is generated.
See also patches to Mail::IMAPClient:
http://rt.cpan.org/Ticket/Display.html?id=42987
Phil
--
Phil Lobbes <phil at zimbra dot com>
Zimbra, a Yahoo! company
--- imapsync.orig 2009-02-03 20:57:23.003625000 -0500
+++ imapsync 2009-02-03 21:05:54.019250000 -0500
@@ -70,7 +70,7 @@
[--minage <int>]
[--skipheader <regex>]
[--useheader <string>] [--useheader <string>]
- [--skipsize]
+ [--skipsize] [--allowsizemismatch]
[--delete] [--delete2]
[--expunge] [--expunge1] [--expunge2]
[--subscribed] [--subscribe]
@@ -463,7 +463,7 @@
$fastio1, $fastio2,
$maxsize, $maxage, $minage,
$skipheader, @useheader,
- $skipsize, $foldersizes, $buffersize,
+ $skipsize, $allowsizemismatch, $foldersizes, $buffersize,
$delete, $delete2,
$expunge, $expunge1, $expunge2, $dry,
$justfoldersizes,
@@ -1421,6 +1421,14 @@
last FOLDER if $from->IsUnconnected();
my $string;
$string = $from->message_string($f_msg);
+ unless (defined($string)) {
+ warn
+ "Could not fetch message #$f_msg from $f_fold ",
+ $from->LastError, "\n";
+ $error++;
+ $mess_size_total_error += $f_size;
+ next MESS;
+ }
#print "AAAmessage_string[$string]ZZZ\n";
#my $message_file = "tmp_imapsync_$$";
#$from->select($f_fold);
@@ -1749,6 +1757,7 @@
"skipheader=s" => \$skipheader,
"useheader=s" => \ at useheader,
"skipsize!" => \$skipsize,
+ "allowsizemismatch!" => \$allowsizemismatch,
"fastio1!" => \$fastio1,
"fastio2!" => \$fastio2,
"ssl1!" => \$ssl1,
@@ -2002,6 +2011,9 @@
Ex: Message-ID or Subject or Date.
--useheader <string> and this one, etc.
--skipsize : Don't take message size into account.
+--allowsizemismatch: allow RFC822.SIZE != fetched msg size
+ consider --skipsize to avoid duplicate messages
+ when running syncs more than one time per mailbox
--dry : do nothing, just print what would be done.
--subscribed : transfers subscribed folders.
--subscribe : subscribe to the folders transferred on the
@@ -2641,6 +2653,13 @@
return undef;
}
$self->Socket($sock);
+ if ( $Mail::IMAPClient::VERSION =~ /^2/ ) {
+ warn("--allowsizemismatch not supported in Mail::IMAPClient $Mail::IMAPClient::VERSION\n");
+ }
+ else {
+ $self->Ignoresizeerrors($allowsizemismatch);
+ }
+
$self->State(Connected);
$sock->autoflush(1) ;
my ($code, $output);