diff options
Diffstat (limited to 'interimap')
-rwxr-xr-x | interimap | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -396,7 +396,7 @@ fail(undef, "Local and remote namespaces are neither both flat nor both hierarch fail(undef, "Local and remote hierachy delimiters differ ", "(local ", print_delimiter($IMAP->{local}->{delimiter}), ", ", "remote ", print_delimiter($IMAP->{remote}->{delimiter}), "), ", - "refusing to update \`mailboxes\` table.") + "refusing to update table \`mailboxes\`.") if defined $IMAP->{local}->{delimiter} and defined $IMAP->{remote}->{delimiter} # we failed earlier if only one of them was NIL and $IMAP->{local}->{delimiter} ne $IMAP->{remote}->{delimiter}; @@ -418,7 +418,7 @@ fail(undef, "Local and remote namespaces are neither both flat nor both hierarch $DBH->do("DROP TABLE mailboxes"); $DBH->do("ALTER TABLE _tmp${DATABASE_VERSION}_mailboxes RENAME TO mailboxes"); } - fail("database", "Broken referential integrity! Refusing to commit changes.") + fail("database", "Broken referential integrity! Refusing to commit changes.") if defined $DBH->selectrow_arrayref("PRAGMA foreign_key_check"); SCHEMA_DONE: $DBH->do("PRAGMA user_version = $DATABASE_VERSION"); @@ -530,6 +530,7 @@ if (defined $COMMAND and $COMMAND eq 'delete') { qw/mapping local remote mailboxes/ if @ARGV and $CONFIG{target}->{database}; foreach my $mailbox (@ARGV) { + fail(undef, "INBOX can't be deleted") if uc($mailbox) eq "INBOX"; # RFC 3501 sec. 6.3.4 my $idx = db_get_mailbox_idx($mailbox); # delete $mailbox on servers where $mailbox exists. note that @@ -636,6 +637,10 @@ sub sync_mailbox_list() { state $sth_subscribe = $DBH->prepare(q{ UPDATE mailboxes SET subscribed = ? WHERE idx = ? }); + state $ignore_mailbox = do { + my $re = $CONF->{_}->{"ignore-mailbox"}; + defined $re ? qr/$re/ : undef + }; foreach my $name (qw/local remote/) { foreach my $mbx (keys %{$IMAP->{$name}->{mailboxes}}) { @@ -645,8 +650,7 @@ sub sync_mailbox_list() { # exclude ignored mailboxes (taken from the default config as it doesn't # make sense to ignore mailboxes from one side but not the other - next if !@ARGV and defined $CONF->{_}->{"ignore-mailbox"} - and $mbx =~ /$CONF->{_}->{"ignore-mailbox"}/o; + next if !@ARGV and defined $ignore_mailbox and $mbx =~ $ignore_mailbox; $mailboxes{$mbx} = 1; } } @@ -789,7 +793,7 @@ sub delete_mapping($$) { # we let the server know that the messages have been EXPUNGEd [RFC7162, # section 3.2.5.2]. # The UID set is the largest set of higest UIDs with at most 1024 UIDs, -# of length (once compacted) at most 64. +# of length (once compacted) at most 256. # The reason why we sample with the highest UIDs is that lowest UIDs are # less likely to be deleted. sub sample($$) { @@ -810,13 +814,14 @@ sub sample($$) { $uids = ($min == $max ? $min : "$min:$max") .(defined $uids ? ','.$uids : ''); $min = $max = $k; - if (length($uids) > 64) { + if (length($uids) > 256) { $sth->finish(); # done with the statement last; } } } - if (!defined $uids or length($uids) <= 64) { + if (!defined $uids or length($uids) <= 256) { + # exceed max size by at most 22 bytes ("$MIN:$MAX,") $n += $max - $min + 1; $uids = ($min == $max ? $min : "$min:$max") . (defined $uids ? ','.$uids : ''); @@ -1161,8 +1166,8 @@ sub callback_new_message($$$$;$$$) { } else { # use MULTIAPPEND (RFC 3502) - # proceed by 1MiB batches to save roundtrips without blowing up the memory - if (@$buff and $$bufflen + $length > 1048576) { + # proceed by batches of 128/1MiB to save roundtrips without blowing up the memory + if ($#$buff >= 127 or (@$buff and $$bufflen + $length > 1048576)) { @UIDs = callback_new_message_flush($idx, $mailbox, $name, @$buff); @$buff = (); $$bufflen = 0; |