From 3c9ab47c7d0e26fd22e1f42a198696b093629802 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 29 May 2019 20:56:32 +0000 Subject: searchidx: store indexlevel=medium as metadata And use it from Admin. It's easy to tell what indexlevel=basic is from unconfigured inboxes, but distinguishing between 'medium' and 'full' would require stat()-ing position.* files which is fragile and Xapian-implementation-dependent. So use the metadata facility of Xapian and store it in the main partition so Admin tools can deal better with unconfigured inboxes copied using generic tools like cp(1) or rsync(1). --- lib/PublicInbox/Admin.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/PublicInbox/Admin.pm') diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm index 07d8b572..4a862c6d 100644 --- a/lib/PublicInbox/Admin.pm +++ b/lib/PublicInbox/Admin.pm @@ -41,6 +41,31 @@ sub resolve_repo_dir { } } +# for unconfigured inboxes +sub detect_indexlevel ($) { + my ($ibx) = @_; + + # brand new or never before indexed inboxes default to full + return 'full' unless $ibx->over; + delete $ibx->{over}; # don't leave open FD lying around + + my $l = 'basic'; + my $srch = $ibx->search or return $l; + delete $ibx->{search}; # don't leave open FD lying around + if (my $xdb = $srch->xdb) { + $l = 'full'; + my $m = $xdb->get_metadata('indexlevel'); + if ($m eq 'medium') { + $l = $m; + } elsif ($m ne '') { + warn <<""; +$ibx->{mainrepo} has unexpected indexlevel in Xapian: $m + + } + } + $l; +} + sub resolve_inboxes { my ($argv, $warn_on_unconfigured) = @_; require PublicInbox::Config; -- cgit v1.2.3-24-ge0c7