about summary refs log tree commit homepage
path: root/script
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-04-06 12:39:52 +0000
committerEric Wong <e@80x24.org>2023-04-06 21:20:50 +0000
commit51a786f7215a2b84114c76fbd6589a55c198af65 (patch)
treed46f60b2793c2de69fc7dc583f10a3e079562aeb /script
parentc32cb39ce267f684c1171bf42e879f797c40e79f (diff)
downloadpublic-inbox-51a786f7215a2b84114c76fbd6589a55c198af65.tar.gz
I favor leaving the publicinbox.<name>.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.
Diffstat (limited to 'script')
-rwxr-xr-xscript/public-inbox-convert2
-rwxr-xr-xscript/public-inbox-index6
2 files changed, 4 insertions, 4 deletions
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});
         }