unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 01/64] inbox: add uidvalidity method
Date: Fri, 16 Oct 2020 06:59:31 +0000	[thread overview]
Message-ID: <20201016070034.22204-1-e@80x24.org> (raw)

This will make it easier to deal with ExtSearchIdx, which
won't have msgmap.
---
 lib/PublicInbox/DummyInbox.pm | 4 ++--
 lib/PublicInbox/IMAPD.pm      | 6 +++---
 lib/PublicInbox/Inbox.pm      | 2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/DummyInbox.pm b/lib/PublicInbox/DummyInbox.pm
index 69b0b683..02426f13 100644
--- a/lib/PublicInbox/DummyInbox.pm
+++ b/lib/PublicInbox/DummyInbox.pm
@@ -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 =
diff --git a/lib/PublicInbox/IMAPD.pm b/lib/PublicInbox/IMAPD.pm
index 3c211ee1..bb705136 100644
--- a/lib/PublicInbox/IMAPD.pm
+++ b/lib/PublicInbox/IMAPD.pm
@@ -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:
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index b0894a7d..cbb95b8d 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -428,4 +428,6 @@ sub on_unlock {
 	}
 }
 
+sub uidvalidity  { $_[0]->{uidvalidity} //= $_[0]->mm->created_at }
+
 1;

             reply	other threads:[~2020-10-16  7:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16  6:59 Eric Wong [this message]
2020-10-16  6:59 ` [PATCH 02/64] git: ensure ->destroy clobbers check_async read buffer Eric Wong
2020-10-16  6:59 ` [PATCH 03/64] git: *_async: support nested callback invocations Eric Wong
2020-10-16  6:59 ` [PATCH 04/64] git: async: loop inflight checks for nested callbacks Eric Wong
2020-10-16  7:02 ` oops, :x was supposed to be 1/3 for git: stuff Eric Wong
2020-10-16  7:03 ` [PATCH 01/64] inbox: add uidvalidity method Eric Wong

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