mirror of
https://github.com/imapsync/imapsync.git
synced 2025-06-05 20:27:20 +02:00
1.137
This commit is contained in:
parent
0620694153
commit
e47a98b809
5 changed files with 130 additions and 18 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,17 +1,21 @@
|
|||
|
||||
RCS file: RCS/imapsync,v
|
||||
Working file: imapsync
|
||||
head: 1.136
|
||||
head: 1.137
|
||||
branch:
|
||||
locks: strict
|
||||
gilles: 1.136
|
||||
access list:
|
||||
symbolic names:
|
||||
keyword substitution: kv
|
||||
total revisions: 136; selected revisions: 136
|
||||
total revisions: 137; selected revisions: 137
|
||||
description:
|
||||
----------------------------
|
||||
revision 1.136 locked by: gilles;
|
||||
revision 1.137
|
||||
date: 2005/06/26 03:08:35; author: gilles; state: Exp; lines: +22 -11
|
||||
Added --fastio1 --fastio2 options.
|
||||
Fixed bad variable declaration with --maxage.
|
||||
----------------------------
|
||||
revision 1.136
|
||||
date: 2005/06/23 02:24:19; author: gilles; state: Exp; lines: +42 -29
|
||||
Fixed --maxsize --skipsize bug
|
||||
----------------------------
|
||||
|
|
4
README
4
README
|
@ -2,7 +2,7 @@ NAME
|
|||
imapsync - IMAP synchronization, copy or migration tool. Synchronize
|
||||
mailboxes between two imap servers. Good at IMAP migration.
|
||||
|
||||
$Revision: 1.136 $
|
||||
$Revision: 1.137 $
|
||||
|
||||
INSTALL
|
||||
imapsync works fine under any Unix OS.
|
||||
|
@ -254,5 +254,5 @@ AUTHOR
|
|||
teaching free open and gratis softwares. Don't hesitate to pay him for
|
||||
that services.
|
||||
|
||||
$Id: imapsync,v 1.136 2005/06/23 02:24:19 gilles Exp gilles $
|
||||
$Id: imapsync,v 1.137 2005/06/26 03:08:35 gilles Exp $
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.136
|
||||
1.137
|
||||
|
|
33
imapsync
33
imapsync
|
@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration
|
|||
tool. Synchronize mailboxes between two imap servers. Good
|
||||
at IMAP migration.
|
||||
|
||||
$Revision: 1.136 $
|
||||
$Revision: 1.137 $
|
||||
|
||||
=head1 INSTALL
|
||||
|
||||
|
@ -296,7 +296,7 @@ Gilles LAMIRAL earn his living writing, installing,
|
|||
configuring and teaching free open and gratis
|
||||
softwares. Don't hesitate to pay him for that services.
|
||||
|
||||
$Id: imapsync,v 1.136 2005/06/23 02:24:19 gilles Exp gilles $
|
||||
$Id: imapsync,v 1.137 2005/06/26 03:08:35 gilles Exp $
|
||||
|
||||
=cut
|
||||
|
||||
|
@ -319,6 +319,7 @@ my(
|
|||
@folder, $include, $exclude, $prefix2, $regextrans2, @regexmess,
|
||||
$sep1, $sep2,
|
||||
$syncinternaldates, $syncacls,
|
||||
$fastio1, $fastio2,
|
||||
$maxsize, $maxage,
|
||||
$skipheader, @useheader,
|
||||
$skipsize, $foldersizes, $buffersize,
|
||||
|
@ -335,13 +336,12 @@ my(
|
|||
$timeout, # whr (ESS/PRW)
|
||||
$timestart, $timeend, $timediff,
|
||||
$timesize, $timebefore,
|
||||
|
||||
);
|
||||
|
||||
use vars qw ($opt_G); # missing code for this will be option.
|
||||
|
||||
|
||||
$rcs = ' $Id: imapsync,v 1.136 2005/06/23 02:24:19 gilles Exp gilles $ ';
|
||||
$rcs = ' $Id: imapsync,v 1.137 2005/06/26 03:08:35 gilles Exp $ ';
|
||||
$rcs =~ m/,v (\d+\.\d+)/;
|
||||
$VERSION = ($1) ? $1 : "UNKNOWN";
|
||||
|
||||
|
@ -378,8 +378,8 @@ $error=0;
|
|||
|
||||
my $banner = join("",
|
||||
'$RCSfile: imapsync,v $ ',
|
||||
'$Revision: 1.136 $ ',
|
||||
'$Date: 2005/06/23 02:24:19 $ ',
|
||||
'$Revision: 1.137 $ ',
|
||||
'$Date: 2005/06/26 03:08:35 $ ',
|
||||
"\n",
|
||||
"Mail::IMAPClient version used here is ",
|
||||
$VERSION_IMAPClient,"\n"
|
||||
|
@ -411,6 +411,10 @@ $authmd5 = (defined($authmd5)) ? $authmd5 : 1;
|
|||
$syncacls = (defined($syncacls)) ? $syncacls : 0;
|
||||
$foldersizes = (defined($foldersizes)) ? $foldersizes : 1;
|
||||
|
||||
$fastio1 = (defined($fastio1)) ? $fastio1 : 1;
|
||||
$fastio2 = (defined($fastio2)) ? $fastio2 : 1;
|
||||
|
||||
|
||||
@useheader = ("ALL") unless (@useheader);
|
||||
|
||||
print "From imap server [$host1] port [$port1] user [$user1]\n";
|
||||
|
@ -442,8 +446,8 @@ my $authmech = "CRAM-MD5";
|
|||
$timestart = time();
|
||||
$timebefore = $timestart;
|
||||
|
||||
my $fastio1 = 1;
|
||||
my $fastio2 = 1;
|
||||
$fastio1 = 1;
|
||||
$fastio2 = 1;
|
||||
|
||||
$debugimap and print "From connection\n";
|
||||
$from = login_imap($host1, $port1, $user1, $password1, $debugimap, $timeout, $fastio1);
|
||||
|
@ -616,7 +620,8 @@ sub foldersizes {
|
|||
# The pb is fetch_hash() can only be applied on ALL messages
|
||||
|
||||
my @msgs = $imap->since(time - 86400 * $maxage);
|
||||
my $smess = scalar(@msgs);
|
||||
$smess = scalar(@msgs);
|
||||
#print "maxage smess $smess " ;
|
||||
foreach my $m (@msgs) {
|
||||
my $s = $imap->size($m)
|
||||
or warn "Could not find size of message $m: $@\n";
|
||||
|
@ -626,7 +631,9 @@ sub foldersizes {
|
|||
my $hashref = {};
|
||||
$smess = $imap->message_count();
|
||||
unless ($smess == 0) {
|
||||
$imap->fetch_hash("RFC822.SIZE",$hashref);
|
||||
#$imap->Ranges(1);
|
||||
$imap->fetch_hash("RFC822.SIZE",$hashref) or die "$@";
|
||||
#$imap->Ranges(0);
|
||||
#print map {$hashref->{$_}->{"RFC822.SIZE"}, " "} keys %$hashref;
|
||||
map {$stot += $hashref->{$_}->{"RFC822.SIZE"}} keys %$hashref;
|
||||
}
|
||||
|
@ -1015,8 +1022,10 @@ sub get_options
|
|||
"skipheader=s" => \$skipheader,
|
||||
"useheader=s" => \@useheader,
|
||||
"skipsize!" => \$skipsize,
|
||||
"fastio1!" => \$fastio1,
|
||||
"fastio2!" => \$fastio2,
|
||||
);
|
||||
|
||||
|
||||
$debug and print "get options: [$opt_ret]\n";
|
||||
|
||||
# just the version
|
||||
|
@ -1168,6 +1177,8 @@ Several options are mandatory.
|
|||
information.
|
||||
--justfolders : just do things about folders (ignore messages).
|
||||
--fast : be faster (does not sync flags).
|
||||
--nofastio1 : don't use fastio with the "from" server.
|
||||
--nofastio2 : don't use fastio with the "destination" server.
|
||||
--timeout <int> : imap connect timeout.
|
||||
--help : print this.
|
||||
|
||||
|
|
97
patches/imapsync.syncuid.diff
Normal file
97
patches/imapsync.syncuid.diff
Normal file
|
@ -0,0 +1,97 @@
|
|||
--- imapsync.orig Tue Jun 14 23:28:32 2005
|
||||
+++ imapsync Wed Jun 15 14:04:14 2005
|
||||
@@ -318,7 +318,7 @@
|
||||
$user1, $user2, $password1, $password2, $passfile1, $passfile2,
|
||||
@folder, $include, $exclude, $prefix2, $regextrans2, @regexmess,
|
||||
$sep1, $sep2,
|
||||
- $syncinternaldates, $syncacls,
|
||||
+ $syncinternaldates, $syncacls, $syncuids,
|
||||
$maxsize, $maxage,
|
||||
$skipheader, @useheader,
|
||||
$skipsize, $foldersizes, $buffersize,
|
||||
@@ -410,6 +410,7 @@
|
||||
$authmd5 = (defined($authmd5)) ? $authmd5 : 1;
|
||||
|
||||
$syncacls = (defined($syncacls)) ? $syncacls : 0;
|
||||
+$syncuids = (defined($syncuids)) ? $syncuids : 0;
|
||||
$foldersizes = (defined($foldersizes)) ? $foldersizes : 1;
|
||||
|
||||
@useheader = ("ALL") unless (@useheader);
|
||||
@@ -661,7 +662,8 @@
|
||||
# needed for setting flags
|
||||
my $tohasuidplus = $to->has_capability("UIDPLUS");
|
||||
|
||||
-
|
||||
+die("Need UIDPLUS on destination server to synchronize UIDs\n")
|
||||
+ if ($syncuids && !$tohasuidplus);
|
||||
|
||||
print
|
||||
"From folders : ", map("[$_] ",@f_folders),"\n",
|
||||
@@ -788,7 +790,7 @@
|
||||
print "Time sizes : ", timenext(), " s\n";
|
||||
#my $f_flags = $from->flags(@f_msgs) ;
|
||||
#print "Time flags : ", timenext(), " s\n";
|
||||
- use Data::Dumper;
|
||||
+ #use Data::Dumper;
|
||||
#print Data::Dumper->Dump([$f_heads]);
|
||||
#print Data::Dumper->Dump([$f_flags]);
|
||||
|
||||
@@ -821,6 +823,7 @@
|
||||
|
||||
#print map { $f_hash{$_}{'m'} . " "} @f_hash_keys_sorted_by_uid;
|
||||
|
||||
+ my $last_uid = 0;
|
||||
MESS: foreach my $m_id (@f_hash_keys_sorted_by_uid) {
|
||||
my $f_size = $f_hash{$m_id}{'s'};
|
||||
my $f_msg = $f_hash{$m_id}{'m'};
|
||||
@@ -835,6 +838,21 @@
|
||||
print "+ NO msg #$f_msg [$m_id] in $t_fold\n";
|
||||
# copy
|
||||
print "+ Copying msg #$f_msg:$f_size to folder $t_fold\n";
|
||||
+ while ($syncuids && !$dry && $last_uid < $f_msg - 1) {
|
||||
+ my $new_id = $to->append_string($t_fold,
|
||||
+ "From: imapsync\r\n".
|
||||
+ "Subject: deleted message\r\n".
|
||||
+ "\r\n".
|
||||
+ "This message has been deleted.\r\n");
|
||||
+ if ($new_id) {
|
||||
+ warn "Inserted padding message #$new_id\n";
|
||||
+ $to->delete_message($new_id);
|
||||
+ $last_uid = $new_id;
|
||||
+ } else {
|
||||
+ warn "Failed to insert padding message\n";
|
||||
+ last;
|
||||
+ }
|
||||
+ }
|
||||
my $string = $from->message_string($f_msg);
|
||||
foreach my $regexmess (@regexmess) {
|
||||
$debug and print "eval \$string =~ $regexmess\n";
|
||||
@@ -883,6 +901,11 @@
|
||||
print "Copied msg id [$f_msg] to folder $t_fold msg id [$new_id]\n";
|
||||
$mess_size_total_trans += $f_size;
|
||||
$mess_trans += 1;
|
||||
+ $last_uid = $new_id;
|
||||
+ if ($syncuids && $last_uid != $f_msg) {
|
||||
+ # not much we can do about this...
|
||||
+ warn "Couldn't preserve message UID\n";
|
||||
+ }
|
||||
}
|
||||
}
|
||||
next MESS;
|
||||
@@ -1002,6 +1025,7 @@
|
||||
"delete!" => \$delete,
|
||||
"syncinternaldates!" => \$syncinternaldates,
|
||||
"syncacls!" => \$syncacls,
|
||||
+ "syncuids!" => \$syncuids,
|
||||
"maxsize=i" => \$maxsize,
|
||||
"maxage=i" => \$maxage,
|
||||
"buffersize=i" => \$buffersize,
|
||||
@@ -1156,6 +1180,8 @@
|
||||
--justconnect. Turned on by default.
|
||||
--syncacls : Synchronizes acls.
|
||||
--nosyncacls : Does not synchronize acls. This is the default.
|
||||
+--syncuids : Synchronizes UIDs.
|
||||
+--nosyncuids : Does not synchronize UIDs. This is the default.
|
||||
--debug : debug mode.
|
||||
--debugimap : imap debug mode.
|
||||
--version : print sotfware version.
|
Loading…
Add table
Add a link
Reference in a new issue