From 51a786f7215a2b84114c76fbd6589a55c198af65 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 6 Apr 2023 12:39:52 +0000 Subject: watch: use detect_indexlevel for unconfigured inboxes I favor leaving the publicinbox..indexlevel parameter out of config files to make it easier to alter and reduce sources of truth. It worked well in most cases, but public-inbox-watch also needs to detect the indexlevel. Moving the sub to InboxWritable (from Admin) probably makes sense since it's a per-inbox attribute and allows -watch to reuse it. --- lib/PublicInbox/InboxWritable.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/PublicInbox/InboxWritable.pm') diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm index 17dfbe18..022e2a69 100644 --- a/lib/PublicInbox/InboxWritable.pm +++ b/lib/PublicInbox/InboxWritable.pm @@ -245,4 +245,31 @@ sub git_dir_latest { "$self->{inboxdir}/git/$$max.git" : undef; } +# for unconfigured inboxes +sub detect_indexlevel ($) { + my ($ibx) = @_; + + my $over = $ibx->over; + my $srch = $ibx->search; + delete @$ibx{qw(over search)}; # don't leave open FDs lying around + + # brand new or never before indexed inboxes default to full + return 'full' unless $over; + my $l = 'basic'; + return $l unless $srch; + if (my $xdb = $srch->xdb) { + $l = 'full'; + my $m = $xdb->get_metadata('indexlevel'); + if ($m eq 'medium') { + $l = $m; + } elsif ($m ne '') { + warn <<""; +$ibx->{inboxdir} has unexpected indexlevel in Xapian: $m + + } + $ibx->{-skip_docdata} = 1 if $xdb->get_metadata('skip_docdata'); + } + $l; +} + 1; -- cgit v1.2.3-24-ge0c7