]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inbox: add uidvalidity method
authorEric Wong <e@80x24.org>
Fri, 16 Oct 2020 06:59:31 +0000 (06:59 +0000)
committerEric Wong <e@80x24.org>
Fri, 16 Oct 2020 17:15:12 +0000 (17:15 +0000)
This will make it easier to deal with ExtSearchIdx, which
won't have msgmap.

lib/PublicInbox/DummyInbox.pm
lib/PublicInbox/IMAPD.pm
lib/PublicInbox/Inbox.pm

index 69b0b6837c7b9a1cbff333a9d4c8fa4235ccf363..02426f13c42f7aa027dd52eb70f2c58f6c09fb1d 100644 (file)
@@ -7,13 +7,13 @@
 package PublicInbox::DummyInbox;
 use strict;
 
-sub created_at { 0 } # Msgmap::created_at
+sub uidvalidity { 0 } # Msgmap::created_at
 sub mm { shift }
 sub uid_range { [] } # Over::uid_range
 sub subscribe_unlock { undef };
 
 no warnings 'once';
-*max = \&created_at;
+*max = \&uidvalidity;
 *query_xover = \&uid_range;
 *over = \&mm;
 *search = *unsubscribe_unlock =
index 3c211ee1bf111568b70040c2b97559f9a88c7580..bb705136aecd5ab86f6e71b9b0ff46b76b5508ec 100644 (file)
@@ -38,13 +38,13 @@ sub imapd_refresh_ibx { # pi_config->each_inbox cb
        }
        $ibx->over or return;
        $ibx->{over} = undef;
-       my $mm = $ibx->mm or return;
-       $ibx->{mm} = undef;
 
        # RFC 3501 2.3.1.1 -  "A good UIDVALIDITY value to use in
        # this case is a 32-bit representation of the creation
        # date/time of the mailbox"
-       defined($ibx->{uidvalidity} = $mm->created_at) or return;
+       eval { $ibx->uidvalidity };
+       my $mm = delete($ibx->{mm}) or return;
+       defined($ibx->{uidvalidity}) or return;
        PublicInbox::IMAP::ensure_slices_exist($imapd, $ibx, $mm->max // 0);
 
        # preload to avoid fragmentation:
index b0894a7d6414d038d820afa4533a2c2f69321ddd..cbb95b8d6204ef756c9b551d9388954e2300c9dc 100644 (file)
@@ -428,4 +428,6 @@ sub on_unlock {
        }
 }
 
+sub uidvalidity  { $_[0]->{uidvalidity} //= $_[0]->mm->created_at }
+
 1;