]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imap: avoid warnings on non-slice mailboxes
authorEric Wong <e@yhbt.net>
Tue, 7 Jul 2020 20:37:37 +0000 (20:37 +0000)
committerEric Wong <e@yhbt.net>
Fri, 10 Jul 2020 11:27:08 +0000 (11:27 +0000)
Non-slice mailboxes never have messages themselves,
so we must not assume a message exists when sending
untagged EXISTS messages.

lib/PublicInbox/IMAP.pm
t/imapd.t

index d8c898f4b511e1f93bfdcfeac59cc5c7e87a99f0..8ab4b1e7dba9e86853e7d93af5bc6c7627f0221e 100644 (file)
@@ -246,6 +246,7 @@ sub uo2m_extend ($$;$) {
        my $base = $self->{uid_base};
        ++$beg;
        my $uids = $self->{ibx}->over->uid_range($beg, $base + UID_SLICE);
+       return $uo2m if !scalar(@$uids);
        my @tmp; # [$UID_OFFSET] => $MSN
        my $write_method = $_[2] // 'msg_more';
        if (ref($uo2m)) {
index 1ac6a4ab64ecc28c4dbdb00286e2d3ce29b2ef45..6cfced411c2288e73877392aab33062eedfdd405 100644 (file)
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -87,12 +87,16 @@ my $post_auth_anon_capa = $mic->capability;
 is_deeply($post_auth_anon_capa, $post_login_capa,
        'auth anon has same capabilities');
 my $e;
+ok($mic->noop, 'NOOP');
+ok($mic->noop, 'NOOP (again)'); # for warnings
 ok(!$mic->examine('foo') && ($e = $@), 'EXAMINE non-existent');
 like($e, qr/\bNO\b/, 'got a NO on EXAMINE for non-existent');
 ok(!$mic->select('foo') && ($e = $@), 'EXAMINE non-existent');
 like($e, qr/\bNO\b/, 'got a NO on EXAMINE for non-existent');
 my $mailbox1 = "inbox.i1.$first_range";
 ok($mic->select('inbox.i1'), 'SELECT on parent succeeds');
+ok($mic->noop, 'NOOP while selected');
+ok($mic->noop, 'NOOP again while selected'); # check warnings later
 ok($mic->select($mailbox1), 'SELECT succeeds');
 ok($mic->examine($mailbox1), 'EXAMINE succeeds');
 my @raw = $mic->status($mailbox1, qw(Messages uidnext uidvalidity));