mirror of
https://github.com/imapsync/imapsync.git
synced 2025-07-30 22:06:07 +02:00
1.285
This commit is contained in:
parent
9ca0e338a4
commit
5cdcc66e9c
11 changed files with 297 additions and 2862 deletions
53
imapsync
53
imapsync
|
@ -9,7 +9,7 @@ tool. Synchronise mailboxes between two imap servers. Good
|
|||
at IMAP migration. More than 32 different IMAP server softwares
|
||||
supported with success.
|
||||
|
||||
$Revision: 1.284 $
|
||||
$Revision: 1.285 $
|
||||
|
||||
=head1 INSTALL
|
||||
|
||||
|
@ -418,7 +418,7 @@ Entries for imapsync:
|
|||
|
||||
Feedback (good or bad) will always be welcome.
|
||||
|
||||
$Id: imapsync,v 1.284 2009/06/30 03:14:24 gilles Exp gilles $
|
||||
$Id: imapsync,v 1.285 2009/07/03 00:59:20 gilles Exp gilles $
|
||||
|
||||
=cut
|
||||
|
||||
|
@ -484,7 +484,7 @@ my(
|
|||
use vars qw ($opt_G); # missing code for this will be option.
|
||||
|
||||
|
||||
$rcs = '$Id: imapsync,v 1.284 2009/06/30 03:14:24 gilles Exp gilles $ ';
|
||||
$rcs = '$Id: imapsync,v 1.285 2009/07/03 00:59:20 gilles Exp gilles $ ';
|
||||
$rcs =~ m/,v (\d+\.\d+)/;
|
||||
$VERSION = ($1) ? $1: "UNKNOWN";
|
||||
|
||||
|
@ -547,8 +547,8 @@ while (@argv_copy) {
|
|||
|
||||
my $banner = join("",
|
||||
'$RCSfile: imapsync,v $ ',
|
||||
'$Revision: 1.284 $ ',
|
||||
'$Date: 2009/06/30 03:14:24 $ ',
|
||||
'$Revision: 1.285 $ ',
|
||||
'$Date: 2009/07/03 00:59:20 $ ',
|
||||
"\n",localhost_info(),
|
||||
" and the module Mail::IMAPClient version used here is ",
|
||||
$VERSION_IMAPClient,"\n",
|
||||
|
@ -1237,7 +1237,7 @@ sub to_folder_name {
|
|||
my ($t_fold);
|
||||
my ($x_fold) = @_;
|
||||
# first we remove the prefix
|
||||
$x_fold =~ s/^$f_prefix//;
|
||||
$x_fold =~ s/^\Q$f_prefix\E//;
|
||||
$debug and print "removed source prefix: [$x_fold]\n";
|
||||
$t_fold = separator_invert($x_fold,$f_sep, $t_sep);
|
||||
$debug and print "inverted separators: [$t_fold]\n";
|
||||
|
@ -1406,9 +1406,11 @@ FOLDER: foreach my $f_fold (@f_folders) {
|
|||
last FOLDER if $from->IsUnconnected();
|
||||
|
||||
foreach my $m (@f_msgs) {
|
||||
unless (parse_header_msg1($from, $m, $f_heads, $f_fir, "F", \%f_hash)) {
|
||||
my $rc = parse_header_msg1($from, $m, $f_heads, $f_fir, "F", \%f_hash);
|
||||
if (!$rc) {
|
||||
my $reason = !defined($rc) ? "no header" : "duplicate";
|
||||
my $f_size = $f_fir->{$m}->{"RFC822.SIZE"} || 0;
|
||||
print "+ Skipping msg #$m:$f_size in folder $f_fold (no header so we ignore this message)\n";
|
||||
print "+ Skipping msg #$m:$f_size in folder $f_fold ($reason so we ignore this message)\n";
|
||||
$mess_size_total_skipped += $f_size;
|
||||
$mess_skipped += 1;
|
||||
}
|
||||
|
@ -1427,7 +1429,14 @@ FOLDER: foreach my $f_fold (@f_folders) {
|
|||
$debug and print "Time fir: ", timenext(), " s\n";
|
||||
last FOLDER if $to->IsUnconnected();
|
||||
foreach my $m (@t_msgs) {
|
||||
parse_header_msg1($to, $m, $t_heads, $t_fir, "T", \%t_hash);
|
||||
my $rc = parse_header_msg1($to, $m, $t_heads, $t_fir, "T", \%t_hash);
|
||||
if (!$rc) {
|
||||
my $reason = !defined($rc) ? "no header" : "duplicate";
|
||||
my $t_size = $t_fir->{$m}->{"RFC822.SIZE"} || 0;
|
||||
print "+ Skipping msg #$m:$t_size in 'to' folder $t_fold ($reason so we ignore this message)\n";
|
||||
#$mess_size_total_skipped += $msize;
|
||||
#$mess_skipped += 1;
|
||||
}
|
||||
}
|
||||
$debug and print "Time headers: ", timenext(), " s\n";
|
||||
|
||||
|
@ -1572,7 +1581,7 @@ FOLDER: foreach my $f_fold (@f_folders) {
|
|||
|
||||
my $flags_f = $f_hash{$m_id}{'F'} || "";
|
||||
# RFC 2060: This flag can not be altered by any client
|
||||
$flags_f =~ s@\\Recent@@gi;
|
||||
$flags_f =~ s@\\Recent\s?@@gi;
|
||||
$flags_f = flags_regex($flags_f) if @regexflag;
|
||||
|
||||
my $new_id;
|
||||
|
@ -1638,14 +1647,24 @@ FOLDER: foreach my $f_fold (@f_folders) {
|
|||
my $flags_f = $f_hash{$m_id}{'F'} || "";
|
||||
my $flags_t = $t_hash{$m_id}{'F'} || "";
|
||||
|
||||
# No flag \Recent here, no ?
|
||||
# RFC 2060: This flag can not be altered by any client
|
||||
$flags_f =~ s@\\Recent\s?@@gi;
|
||||
$flags_f = flags_regex($flags_f) if @regexflag;
|
||||
|
||||
$debug and print "Setting flags from($flags_f) to($flags_t)\n";
|
||||
# compare flags - add missing flags
|
||||
my @ff = split(' ', $flags_f );
|
||||
my %ft = map { $_ => 1 } split(' ', $flags_t );
|
||||
my @flags_a = map { exists $ft{$_} ? () : $_ } @ff;
|
||||
|
||||
# This add or change flags but no flag are removed with this
|
||||
$to->store($t_msg, "+FLAGS.SILENT ($flags_f)" )
|
||||
if (!$dry and $flags_f ne $flags_t);
|
||||
$debug and print "Setting flags(@flags_a) ffrom($flags_f) fto($flags_t) on msg #$t_msg in $t_fold\n";
|
||||
|
||||
# This adds or changes flags but no flag are removed with this
|
||||
if (!$dry and @flags_a and !$to->store($t_msg, "+FLAGS.SILENT (@flags_a)") ) {
|
||||
warn "Could not add flags '@flags_a' flagf '$flags_f'",
|
||||
" flagt '$flags_t' on msg #$t_msg in $t_fold: ",
|
||||
$to->LastError, "\n";
|
||||
#$error++;
|
||||
}
|
||||
last FOLDER if $to->IsUnconnected();
|
||||
|
||||
$debug and do {
|
||||
|
@ -1971,7 +1990,7 @@ sub parse_header_msg1 {
|
|||
#$headstr = $imap->message_string($m_uid);
|
||||
|
||||
print "no header so we ignore this message\n";
|
||||
return;
|
||||
return undef;
|
||||
}
|
||||
my $size = $s_fir->{$m_uid}->{"RFC822.SIZE"};
|
||||
my $flags = $s_fir->{$m_uid}->{"FLAGS"};
|
||||
|
@ -1986,6 +2005,8 @@ sub parse_header_msg1 {
|
|||
else {
|
||||
$key = "$m_md5:$size";
|
||||
}
|
||||
# 0 return code is used to identify duplicate message hash
|
||||
return 0 if exists $s_hash->{"$key"};
|
||||
$s_hash->{"$key"}{'5'} = $m_md5;
|
||||
$s_hash->{"$key"}{'s'} = $size;
|
||||
$s_hash->{"$key"}{'D'} = $idate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue