From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] imap: STATUS: count messages properly
Date: Fri, 8 Jul 2022 11:36:37 +0000 [thread overview]
Message-ID: <20220708113637.1241370-1-e@80x24.org> (raw)
This only affects the rarely-used STATUS command, our message
count was consistely zero due to misusing ->imap_exists.
Noticed while implementing POP3 server.
---
lib/PublicInbox/IMAP.pm | 3 ++-
t/imapd.t | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index d47e4c2f..7e695fd8 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -399,7 +399,8 @@ sub inbox_lookup ($$;$) {
$self->{ibx} = $ibx;
$self->{uo2m} = uo2m_ary_new($self, \$exists);
} else {
- $exists = $over->imap_exists;
+ my $uid_end = $uid_base + UID_SLICE;
+ $exists = $over->imap_exists($uid_base, $uid_end);
}
ensure_slices_exist($self->{imapd}, $ibx, $over->max);
} else {
diff --git a/t/imapd.t b/t/imapd.t
index 80757a9d..43de8675 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -1,5 +1,5 @@
#!perl -w
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# end-to-end IMAP tests, see unit tests in t/imap.t, too
use strict;
@@ -99,7 +99,8 @@ ok($mic->examine($mailbox1), 'EXAMINE succeeds');
my @raw = $mic->status($mailbox1, qw(Messages uidnext uidvalidity));
is(scalar(@raw), 2, 'got status response');
like($raw[0], qr/\A\*\x20STATUS\x20inbox\.i1\.$first_range\x20
- \(MESSAGES\x20\d+\x20UIDNEXT\x20\d+\x20UIDVALIDITY\x20\d+\)\r\n/sx);
+ \(MESSAGES\x20[1-9][0-9]*\x20
+ UIDNEXT\x20\d+\x20UIDVALIDITY\x20\d+\)\r\n/sx);
like($raw[1], qr/\A\S+ OK /, 'finished status response');
my @orig_list = @raw = $mic->list;
reply other threads:[~2022-07-08 11:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220708113637.1241370-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).