This commit is contained in:
Nick Bebout 2011-03-12 02:44:16 +00:00
parent 2a4d29a7c2
commit 0620694153
7 changed files with 60 additions and 37 deletions

View file

@ -1,5 +1,8 @@
#!/bin/cat #!/bin/cat
Mark Waters
Had a problem with --maxsize --skipsize (a bug)
Costa Tsaousis Costa Tsaousis
Had a problem with a huge mailbox (20000 messages) Had a problem with a huge mailbox (20000 messages)

View file

@ -1,15 +1,20 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.135 head: 1.136
branch: branch:
locks: strict locks: strict
gilles: 1.136
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 135; selected revisions: 135 total revisions: 136; selected revisions: 136
description: description:
---------------------------- ----------------------------
revision 1.136 locked by: gilles;
date: 2005/06/23 02:24:19; author: gilles; state: Exp; lines: +42 -29
Fixed --maxsize --skipsize bug
----------------------------
revision 1.135 revision 1.135
date: 2005/06/21 01:29:44; author: gilles; state: Exp; lines: +25 -33 date: 2005/06/21 01:29:44; author: gilles; state: Exp; lines: +25 -33
Removed md5 test on perl lib Removed md5 test on perl lib

9
README
View file

@ -2,7 +2,7 @@ NAME
imapsync - IMAP synchronization, copy or migration tool. Synchronize imapsync - IMAP synchronization, copy or migration tool. Synchronize
mailboxes between two imap servers. Good at IMAP migration. mailboxes between two imap servers. Good at IMAP migration.
$Revision: 1.135 $ $Revision: 1.136 $
INSTALL INSTALL
imapsync works fine under any Unix OS. imapsync works fine under any Unix OS.
@ -220,8 +220,9 @@ HUGE MIGRATION
And the shell program is just : And the shell program is just :
{ while IFS=';' read u1 p1 u2 p2; do imapsync --user1 $u1 --password1 { while IFS=';' read u1 p1 u2 p2; do
$p1 --user2 $u2 --password2 $p2 ... done ; } < file.csv imapsync --user1 "$u1" --password1 "$p1" --user2 "$u2" --password2 "$p2" ...
done ; } < file.csv
Welcome in shell programming ! Welcome in shell programming !
@ -253,5 +254,5 @@ AUTHOR
teaching free open and gratis softwares. Don't hesitate to pay him for teaching free open and gratis softwares. Don't hesitate to pay him for
that services. that services.
$Id: imapsync,v 1.135 2005/06/21 01:29:44 gilles Exp $ $Id: imapsync,v 1.136 2005/06/23 02:24:19 gilles Exp gilles $

View file

@ -1 +1 @@
1.135 1.136

View file

@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration
tool. Synchronize mailboxes between two imap servers. Good tool. Synchronize mailboxes between two imap servers. Good
at IMAP migration. at IMAP migration.
$Revision: 1.135 $ $Revision: 1.136 $
=head1 INSTALL =head1 INSTALL
@ -256,9 +256,9 @@ user0011;password0011;user0012;password0012
And the shell program is just : And the shell program is just :
{ while IFS=';' read u1 p1 u2 p2; do { while IFS=';' read u1 p1 u2 p2; do
imapsync --user1 $u1 --password1 $p1 --user2 $u2 --password2 $p2 ... imapsync --user1 "$u1" --password1 "$p1" --user2 "$u2" --password2 "$p2" ...
done ; } < file.csv done ; } < file.csv
Welcome in shell programming ! Welcome in shell programming !
@ -296,7 +296,7 @@ Gilles LAMIRAL earn his living writing, installing,
configuring and teaching free open and gratis configuring and teaching free open and gratis
softwares. Don't hesitate to pay him for that services. softwares. Don't hesitate to pay him for that services.
$Id: imapsync,v 1.135 2005/06/21 01:29:44 gilles Exp $ $Id: imapsync,v 1.136 2005/06/23 02:24:19 gilles Exp gilles $
=cut =cut
@ -341,7 +341,7 @@ my(
use vars qw ($opt_G); # missing code for this will be option. use vars qw ($opt_G); # missing code for this will be option.
$rcs = ' $Id: imapsync,v 1.135 2005/06/21 01:29:44 gilles Exp $ '; $rcs = ' $Id: imapsync,v 1.136 2005/06/23 02:24:19 gilles Exp gilles $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
@ -378,8 +378,8 @@ $error=0;
my $banner = join("", my $banner = join("",
'$RCSfile: imapsync,v $ ', '$RCSfile: imapsync,v $ ',
'$Revision: 1.135 $ ', '$Revision: 1.136 $ ',
'$Date: 2005/06/21 01:29:44 $ ', '$Date: 2005/06/23 02:24:19 $ ',
"\n", "\n",
"Mail::IMAPClient version used here is ", "Mail::IMAPClient version used here is ",
$VERSION_IMAPClient,"\n" $VERSION_IMAPClient,"\n"
@ -455,6 +455,10 @@ $to = login_imap($host2, $port2, $user2, $password2, $debugimap, $timeout, $fast
$from->Clear(2); $from->Clear(2);
$to->Clear(2); $to->Clear(2);
$debug and print "From Buffer I/O : ", $from->Buffer(), "\n";
$debug and print "To Buffer I/O : ", $to->Buffer(), "\n";
sub login_imap { sub login_imap {
my($host, $port, $user, $password, my($host, $port, $user, $password,
@ -557,6 +561,11 @@ $debug and print "Getting separators\n";
$f_sep = get_separator($from, $sep1, "--sep1"); $f_sep = get_separator($from, $sep1, "--sep1");
$t_sep = get_separator($to, $sep2, "--sep2"); $t_sep = get_separator($to, $sep2, "--sep2");
my $f_namespace = $from->namespace();
my $t_namespace = $to->namespace();
$debug and print "From namespace:\n", Data::Dumper->Dump($f_namespace);
$debug and print "To namespace:\n", Data::Dumper->Dump($t_namespace);
sub get_separator { sub get_separator {
my($imap, $sep_in, $sep_opt) = @_; my($imap, $sep_in, $sep_opt) = @_;
my($sep_out); my($sep_out);
@ -767,11 +776,7 @@ FOLDER: foreach my $f_fold (@f_folders) {
#print "From Buffer I/O : ", $from->Buffer(), "\n"; print "++++ From [$f_fold] Parse 1 ++++\n";
#print "To Buffer I/O : ", $to->Buffer(), "\n";
print "++++ From Parse 1 ++++\n";
my $f_heads = $from->parse_headers($from->Range([@f_msgs]),@useheader) my $f_heads = $from->parse_headers($from->Range([@f_msgs]),@useheader)
if (@f_msgs) ; if (@f_msgs) ;
@ -784,13 +789,12 @@ FOLDER: foreach my $f_fold (@f_folders) {
#print Data::Dumper->Dump([$f_heads]); #print Data::Dumper->Dump([$f_heads]);
#print Data::Dumper->Dump([$f_flags]); #print Data::Dumper->Dump([$f_flags]);
#exit;
foreach my $m (@f_msgs) { foreach my $m (@f_msgs) {
parse_header_msg1($m, $f_heads, $f_size, "F", \%f_hash); parse_header_msg1($from, $m, $f_heads, $f_size, "F", \%f_hash);
} }
$debug and print "Time headers: ", timenext(), " s\n"; $debug and print "Time headers: ", timenext(), " s\n";
print "++++ To Parse 1 ++++\n"; print "++++ To [$t_fold] Parse 1 ++++\n";
my $t_heads = $to->parse_headers($to->Range([@t_msgs]),@useheader) my $t_heads = $to->parse_headers($to->Range([@t_msgs]),@useheader)
if (@t_msgs); if (@t_msgs);
$debug and print "Time headers: ", timenext(), " s\n"; $debug and print "Time headers: ", timenext(), " s\n";
@ -800,12 +804,12 @@ FOLDER: foreach my $f_fold (@f_folders) {
#print "Time flags : ", timenext(), " s\n"; #print "Time flags : ", timenext(), " s\n";
foreach my $m (@t_msgs) { foreach my $m (@t_msgs) {
parse_header_msg1($m, $t_heads, $t_size, "T", \%t_hash); parse_header_msg1($to, $m, $t_heads, $t_size, "T", \%t_hash);
} }
$debug and print "Time headers: ", timenext(), " s\n"; $debug and print "Time headers: ", timenext(), " s\n";
#exit; #exit;
print "++++ Verifying ++++\n"; print "++++ Verifying [$f_fold] -> [$t_fold] ++++\n";
# messages in "from" that are not good in "to" # messages in "from" that are not good in "to"
my @f_hash_keys_sorted_by_uid my @f_hash_keys_sorted_by_uid
@ -918,7 +922,7 @@ FOLDER: foreach my $f_fold (@f_folders) {
# print "!!! Dates differ !!!\n"; # print "!!! Dates differ !!!\n";
#} #}
}; };
unless ($f_size == $t_size) { unless (($f_size == $t_size) or $skipsize) {
# Bad size # Bad size
print print
"Message $m_id SZ_BAD f:$f_msg:$f_size t:$t_msg:$t_size\n"; "Message $m_id SZ_BAD f:$f_msg:$f_size t:$t_msg:$t_size\n";
@ -1029,12 +1033,12 @@ sub get_options
sub parse_header_msg1 { sub parse_header_msg1 {
my ($m_uid, $s_heads, $s_size, $s, $s_hash) = @_; my ($imap, $m_uid, $s_heads, $s_size, $s, $s_hash) = @_;
my $head = $s_heads->{$m_uid}; my $head = $s_heads->{$m_uid};
my $headnum = scalar(keys(%$head)); my $headnum = scalar(keys(%$head));
$debug and print "Head NUM:", $headnum, "\n"; $debug and print "Head NUM:", $headnum, "\n";
return unless($headnum); unless($headnum) { print "Warning : no header used or found \n"; }
my $headstr; my $headstr;
foreach my $h (sort keys(%$head)){ foreach my $h (sort keys(%$head)){
@ -1052,16 +1056,25 @@ sub parse_header_msg1 {
$headstr .= "$h:". $val; $headstr .= "$h:". $val;
} }
} }
return unless ($headstr); #return unless ($headstr);
unless ($headstr){
# no header so taking everything
$headstr = $imap->message_string($m_uid);
}
my $size = $s_size->{$m_uid}->{"RFC822.SIZE"}; my $size = $s_size->{$m_uid}->{"RFC822.SIZE"};
return unless ($size); #return unless ($size);
my $m_md5 = md5_base64($headstr); $size = length($headstr) unless ($size);
my $m_md5 = md5_base64($headstr);
$debug and print "$s msg $m_uid:$m_md5:$size\n"; $debug and print "$s msg $m_uid:$m_md5:$size\n";
$size = 0 if ($skipsize); my $key;
$s_hash->{"$m_md5:$size"}{'5'} = "$m_md5:$size"; if ($skipsize) {
$s_hash->{"$m_md5:$size"}{'s'} = $size; $key = "$m_md5";
$s_hash->{"$m_md5:$size"}{'m'} = $m_uid; }else {
$key = "$m_md5:$size";
}
$s_hash->{"$key"}{'5'} = $m_md5;
$s_hash->{"$key"}{'s'} = $size;
$s_hash->{"$key"}{'m'} = $m_uid;
} }

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
{while IFS=';' read u1 p1 u2 p2; do {while IFS=';' read u1 p1 u2 p2; do
imapsync --user1 $u1 --password1 $p1 --user2 $u2 --password2 $p2 ... imapsync --user1 "$u1" --password1 "$p1" --user2 "$u2" --password2 "$p2" ...
done ; } < file.csv done ; } < file.csv

View file

@ -1,4 +1,5 @@
# How to remove a message by hand.
telnet imap.truc.com 143 telnet imap.truc.com 143
a01 CAPABILITY a01 CAPABILITY