##############################################################################
# Synchronize mailbox and subscription lists
-my @MAILBOXES;
sub sync_mailbox_list() {
- my %mailboxes;
+ my (%mailboxes, @mailboxes);
$mailboxes{$_} = 1 foreach keys %{$IMAP->{local}->{mailboxes}};
$mailboxes{$_} = 1 foreach keys %{$IMAP->{remote}->{mailboxes}};
my $sth_subscribe = $DBH->prepare(q{UPDATE mailboxes SET subscribed = ? WHERE idx = ?});
};
check_delim($mailbox); # ensure that the delimiter match
- push @MAILBOXES, $mailbox unless grep {lc $_ eq lc '\NoSelect'} @attrs;
+ push @mailboxes, $mailbox unless grep {lc $_ eq lc '\NoSelect'} @attrs;
$STH_GET_INDEX->execute($mailbox);
my ($idx,$subscribed) = $STH_GET_INDEX->fetchrow_array();
$DBH->commit();
}
}
+ return @mailboxes;
}
-sync_mailbox_list();
+my @MAILBOXES = sync_mailbox_list();
($lIMAP, $rIMAP) = map {$IMAP->{$_}->{client}} qw/local remote/;
my $ATTRS = join ' ', qw/MODSEQ FLAGS INTERNALDATE BODY.PEEK[]/;
sleep $CONFIG{watch};
# Refresh the mailbox list and status
@{$IMAP->{$_}}{qw/mailboxes delims/} = $IMAP->{$_}->{client}->list($LIST, @LIST_PARAMS) for qw/local remote/;
- sync_mailbox_list();
+ @MAILBOXES = sync_mailbox_list();
}
END { cleanup(); }