unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] imap: STATUS: count messages properly
@ 2022-07-08 11:36 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2022-07-08 11:36 UTC (permalink / raw)
  To: meta

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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-08 11:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 11:36 [PATCH] imap: STATUS: count messages properly Eric Wong

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).