aboutsummaryrefslogtreecommitdiffstats
path: root/imapsync
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2015-07-27 23:45:09 +0200
committerGuilhem Moulin <guilhem@fripost.org>2015-07-27 23:49:59 +0200
commit36b7d017145bac2f883cca12289e66b6b369a5e3 (patch)
tree068ff5c50d55f21dd376acc38da37b9f8b6b8b1a /imapsync
parent67b2781d691d107f92409ac6fd9aeef97593ffa1 (diff)
Enable fine-grained control on the mailboxes to consider.
Add 3 options: - list-mailbox - list-select-opts - ignore-mailbox The first two control the initial LIST command, while the last one is a regular expression to filter out mailboxes to exclude from the LIST response.
Diffstat (limited to 'imapsync')
-rwxr-xr-ximapsync11
1 files changed, 9 insertions, 2 deletions
diff --git a/imapsync b/imapsync
index 2a1bfcc..cc34287 100755
--- a/imapsync
+++ b/imapsync
@@ -66,7 +66,11 @@ usage(1) if defined $COMMAND and (($COMMAND eq 'delete' and !@ARGV) or $COMMAND
my $CONF = read_config( delete $CONFIG{config} // $NAME
, [qw/_ local remote/]
, database => qr/\A(\P{Control}+)\z/
- , logfile => qr/\A(\P{Control}+)\z/ );
+ , logfile => qr/\A(\/\P{Control}+)\z/
+ , 'list-mailbox' => qr/\A([\x01-\x09\x0B\x0C\x0E-\x7F]+)\z/
+ , 'list-select-opts' => qr/\A([\x21\x23\x24\x26\x27\x2B-\x5B\x5E-\x7A\x7C-\x7E]+)\z/
+ , 'ignore-mailbox' => qr/\A([\x01-\x09\x0B\x0C\x0E-\x7F]+)\z/
+ );
my ($DBFILE, $LOCKFILE, $LOGGER_FD);
{
@@ -238,7 +242,8 @@ foreach my $name (qw/local remote/) {
my $list = '"" ';
my @params;
if (!defined $COMMAND or $COMMAND eq 'repair') {
- $list .= '"*"' unless @ARGV;
+ $list = '('.uc($CONF->{_}->{'list-select-opts'}).') '.$list if defined $CONF->{_}->{'list-select-opts'};
+ $list .= (defined $CONF->{_}->{'list-mailbox'} ? '('.$CONF->{_}->{'list-mailbox'}.')' : '*') unless @ARGV;
@params = ('SUBSCRIBED', 'STATUS (UIDVALIDITY UIDNEXT HIGHESTMODSEQ)');
}
$list .= $#ARGV == 0 ? Net::IMAP::Sync::quote($ARGV[0])
@@ -404,6 +409,8 @@ my @MAILBOXES;
my $sth_subscribe = $DBH->prepare(q{UPDATE mailboxes SET subscribed = ? WHERE idx = ?});
@MAILBOXES = keys %mailboxes;
+ @MAILBOXES = grep !/$CONF->{_}->{'ignore-mailbox'}/, @MAILBOXES
+ if defined $CONF->{_}->{'ignore-mailbox'};
foreach my $mailbox (@MAILBOXES) {
check_delim($mailbox); # ensure that the delimiter match