about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-16 06:19:08 +0000
committerEric Wong <e@yhbt.net>2020-06-16 21:42:02 +0000
commit74c897120af8ac4cac17d9f76d21c84f903e24be (patch)
treed4e236b80d3c3b1c5f83e7dc4e6cff6f8b8d9587
parent9c2bac94376c5029d258fed1ad3bf8c6b2270019 (diff)
downloadpublic-inbox-74c897120af8ac4cac17d9f76d21c84f903e24be.tar.gz
We need to clear the UID-offset-to-MSN mapping when
leaving mailboxes via EXAMINE/SELECT/CLOSE.

Furthermore, uo2m_last_uid() needs to account for tiny mailboxes
where the scalar representation of {uo2m} may be evaluated to
`false' in a boolean context.
-rw-r--r--lib/PublicInbox/IMAP.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 64b57a3e..d8b1fce1 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -166,7 +166,7 @@ sub cmd_login ($$$$) {
 
 sub cmd_close ($$) {
         my ($self, $tag) = @_;
-        delete $self->{uid_base};
+        delete @$self{qw(uid_base uo2m)};
         delete $self->{ibx} ? "$tag OK Close done\r\n"
                                 : "$tag BAD No mailbox\r\n";
 }
@@ -220,7 +220,7 @@ sub uo2m_hibernate ($) {
 
 sub uo2m_last_uid ($) {
         my ($self) = @_;
-        my $uo2m = $self->{uo2m} or die 'BUG: uo2m_last_uid w/o {uo2m}';
+        defined(my $uo2m = $self->{uo2m}) or die 'BUG: uo2m_last_uid w/o {uo2m}';
         (ref($uo2m) ? @$uo2m : (length($uo2m) >> 1)) + $self->{uid_base};
 }
 
@@ -415,6 +415,7 @@ sub cmd_examine ($$$) {
         my ($ibx, $exists, $uidnext, $base) = inbox_lookup($self, $mailbox);
         return "$tag NO Mailbox doesn't exist: $mailbox\r\n" if !$ibx;
         $self->{uid_base} = $base;
+        delete $self->{uo2m};
 
         # XXX: do we need this? RFC 5162/7162
         my $ret = $self->{ibx} ? "* OK [CLOSED] previous closed\r\n" : '';