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. --- script/public-inbox-convert | 2 +- script/public-inbox-index | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'script') diff --git a/script/public-inbox-convert b/script/public-inbox-convert index 5f4f2020..750adca4 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -63,7 +63,7 @@ if (delete $old->{-unconfigured}) { } die "Only conversion from v1 inboxes is supported\n" if $old->version >= 2; -my $detected = PublicInbox::Admin::detect_indexlevel($old); +my $detected = $old->detect_indexlevel; $old->{indexlevel} //= $detected; my $env; if ($opt->{'index'}) { diff --git a/script/public-inbox-index b/script/public-inbox-index index a04be9fc..f29e7c3c 100755 --- a/script/public-inbox-index +++ b/script/public-inbox-index @@ -66,6 +66,7 @@ $opt->{-use_cwd} = 1; my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt, $cfg); PublicInbox::Admin::require_or_die('-index'); unless (@ibxs) { print STDERR $help; exit 1 } +require PublicInbox::InboxWritable; my (@eidx, %eidx_seen); my $update_extindex = $opt->{'update-extindex'}; @@ -96,8 +97,9 @@ for my $ei_name (@$update_extindex) { my $mods = {}; my @eidx_unconfigured; foreach my $ibx (@ibxs) { + $ibx = PublicInbox::InboxWritable->new($ibx); # detect_indexlevel may also set $ibx->{-skip_docdata} - my $detected = PublicInbox::Admin::detect_indexlevel($ibx); + my $detected = $ibx->detect_indexlevel; # XXX: users can shoot themselves in the foot, with opt->{indexlevel} $ibx->{indexlevel} //= $opt->{indexlevel} // ($opt->{xapian_only} ? 'full' : $detected); @@ -117,11 +119,9 @@ $opt->{compact} = 0 if !$mods->{'Search::Xapian'}; PublicInbox::Admin::require_or_die(keys %$mods); my $env = PublicInbox::Admin::index_prepare($opt, $cfg); local %ENV = (%ENV, %$env) if $env; -require PublicInbox::InboxWritable; PublicInbox::Xapcmd::check_compact() if $opt->{compact}; PublicInbox::Admin::progress_prepare($opt); for my $ibx (@ibxs) { - $ibx = PublicInbox::InboxWritable->new($ibx); if ($opt->{compact} >= 2) { PublicInbox::Xapcmd::run($ibx, 'compact', $opt->{compact_opt}); } -- cgit v1.2.3-24-ge0c7