]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAP.pm
imapd: use nntpd_cache to speed up startup/reload time
[public-inbox.git] / lib / PublicInbox / IMAP.pm
index 805f1102536d99d9cf77807f86e1b0b3e6290ce4..9955984b0997e28ba86ce196903f2b6e920d3650 100644 (file)
@@ -121,7 +121,7 @@ sub capa ($) {
                $capa .= ' COMPRESS=DEFLATE';
        } else {
                if (!($self->{sock} // $self)->can('accept_SSL') &&
-                       $self->{imapd}->{accept_tls}) {
+                       $self->{imapd}->{ssl_ctx_opt}) {
                        $capa .= ' STARTTLS';
                }
                $capa .= ' AUTH=ANONYMOUS';
@@ -350,12 +350,12 @@ sub idle_done ($$) {
        "$idle_tag OK Idle done\r\n";
 }
 
-sub ensure_slices_exist ($$$) {
-       my ($imapd, $ibx, $max) = @_;
-       defined(my $mb_top = $ibx->{newsgroup}) or return;
+sub ensure_slices_exist ($$) {
+       my ($imapd, $ibx) = @_;
+       my $mb_top = $ibx->{newsgroup} // return;
        my $mailboxes = $imapd->{mailboxes};
        my @created;
-       for (my $i = int($max/UID_SLICE); $i >= 0; --$i) {
+       for (my $i = int($ibx->art_max/UID_SLICE); $i >= 0; --$i) {
                my $sub_mailbox = "$mb_top.$i";
                last if exists $mailboxes->{$sub_mailbox};
                $mailboxes->{$sub_mailbox} = $ibx;
@@ -387,7 +387,8 @@ sub inbox_lookup ($$;$) {
                        my $uid_end = $uid_base + UID_SLICE;
                        $exists = $over->imap_exists($uid_base, $uid_end);
                }
-               ensure_slices_exist($self->{imapd}, $ibx, $over->max);
+               delete $ibx->{-art_max};
+               ensure_slices_exist($self->{imapd}, $ibx);
        } else {
                if ($examine) {
                        $self->{uid_base} = $uid_base;
@@ -396,9 +397,9 @@ sub inbox_lookup ($$;$) {
                }
                # if "INBOX.foo.bar" is selected and "INBOX.foo.bar.0",
                # check for new UID ranges (e.g. "INBOX.foo.bar.1")
-               if (my $z = $self->{imapd}->{mailboxes}->{"$mailbox.0"}) {
-                       ensure_slices_exist($self->{imapd}, $z,
-                                               $z->over(1)->max);
+               if (my $ibx = $self->{imapd}->{mailboxes}->{"$mailbox.0"}) {
+                       delete $ibx->{-art_max};
+                       ensure_slices_exist($self->{imapd}, $ibx);
                }
        }
        ($ibx, $exists, $uidmax + 1, $uid_base);
@@ -595,7 +596,7 @@ sub fetch_blob_cb { # called by git->cat_async via ibx_async_cat
                                        \&fetch_blob_cb, $fetch_arg);
        }
        fetch_run_ops($self, $smsg, $bref, $ops, $partial);
-       $pre ? $self->zflush : $self->requeue_once;
+       $pre ? $self->dflush : $self->requeue_once;
 }
 
 sub emit_rfc822 {
@@ -1230,14 +1231,12 @@ sub cmd_compress ($$$) {
 
 sub cmd_starttls ($$) {
        my ($self, $tag) = @_;
-       my $sock = $self->{sock} or return;
-       if ($sock->can('stop_SSL') || $self->compressed) {
+       (($self->{sock} // return)->can('stop_SSL') || $self->compressed) and
                return "$tag BAD TLS or compression already enabled\r\n";
-       }
-       my $opt = $self->{imapd}->{accept_tls} or
+       $self->{imapd}->{ssl_ctx_opt} or
                return "$tag BAD can not initiate TLS negotiation\r\n";
        $self->write(\"$tag OK begin TLS negotiation now\r\n");
-       $self->{sock} = IO::Socket::SSL->start_SSL($sock, %$opt);
+       PublicInbox::TLS::start($self->{sock}, $self->{imapd});
        $self->requeue if PublicInbox::DS::accept_tls_step($self);
        undef;
 }