aboutsummaryrefslogtreecommitdiffstats
path: root/imapsync
diff options
context:
space:
mode:
Diffstat (limited to 'imapsync')
-rwxr-xr-ximapsync22
1 files changed, 18 insertions, 4 deletions
diff --git a/imapsync b/imapsync
index eb8f652..4ef47b3 100755
--- a/imapsync
+++ b/imapsync
@@ -444,6 +444,20 @@ my @SUBSCRIPTIONS;
push @{$IMAP->{$unsubscribed}->{mailboxes}->{$mbx}}, '\Subscribed';
}
}
+ else {
+ $sth_search->execute($mbx);
+ my $row = $sth_search->fetch();
+ die if defined $sth_search->fetch(); # sanity check
+
+ if (defined $row) {
+ my ($idx,$status) = @$row;
+ unless (defined $status and $status != 0) {
+ my $subscribed = subscribed_mbx('local',$mbx) ? 1 : 0;
+ $sth_subscribe->execute($subscribed, $idx);
+ $DBH->commit();
+ }
+ }
+ }
push @SUBSCRIPTIONS, $mbx if subscribed_mbx('local', $mbx) and
subscribed_mbx('remote',$mbx);
}
@@ -713,7 +727,7 @@ sub sync_messages($$) {
# new mailbox
if (!defined $$idx) {
- my $subscribed = grep { $_ eq $mailbox} @SUBSCRIPTIONS ? 1 : 0;
+ my $subscribed = (grep { $_ eq $mailbox} @SUBSCRIPTIONS) ? 1 : 0;
$STH_NEWMAILBOX->execute($mailbox, $subscribed);
$STH_GET_INDEX->execute($mailbox);
($$idx) = $STH_GET_INDEX->fetchrow_array();
@@ -738,9 +752,8 @@ sub sync_messages($$) {
}
-
-# Wait for notifications on either IMAP server, up to $timout. Then
-# issue a NOOP so the connection doesn't terminate for inactivity.
+# Wait up to $timout seconds for notifications on either IMAP server.
+# Then issue a NOOP so the connection doesn't terminate for inactivity.
sub wait_notifications(;$) {
my $timeout = shift // 300;
@@ -753,6 +766,7 @@ sub wait_notifications(;$) {
if (--$timeout == 0) {
$lIMAP->noop();
$rIMAP->noop();
+ # might have got updates so exit the loop
}
}
}