]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Admin.pm
treewide: s/sequential_shard/sequential-shard/g
[public-inbox.git] / lib / PublicInbox / Admin.pm
index b468108e8ab654f8cb7288c65dff0905c7b776ea..eb38dd8fd384e73ab3de4425258e065a2e1e4873 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # common stuff for administrative command-line tools
@@ -10,6 +10,7 @@ our @EXPORT_OK = qw(setup_signals);
 use PublicInbox::Config;
 use PublicInbox::Inbox;
 use PublicInbox::Spawn qw(popen_rd);
+use PublicInbox::Eml;
 *rel2abs_collapsed = \&PublicInbox::Config::rel2abs_collapsed;
 
 sub setup_signals {
@@ -241,12 +242,10 @@ sub index_inbox {
        }
        local %SIG = %SIG;
        setup_signals(\&index_terminate, $ibx);
-       my $warn_cb = $SIG{__WARN__} // sub { print STDERR @_ };
        my $idx = { current_info => $ibx->{inboxdir} };
-       my $warn_ignore = PublicInbox::InboxWritable->can('warn_ignore');
        local $SIG{__WARN__} = sub {
-               return if $warn_ignore->(@_);
-               $warn_cb->($idx->{current_info}, ': ', @_);
+               return if PublicInbox::Eml::warn_ignore(@_);
+               warn($idx->{current_info}, ': ', @_);
        };
        if (ref($ibx) && $ibx->version == 2) {
                eval { require PublicInbox::V2Writable };
@@ -274,8 +273,8 @@ EOM
        $idx->{nidx} // 0; # returns number processed
 }
 
-sub progress_prepare ($) {
-       my ($opt) = @_;
+sub progress_prepare ($;$) {
+       my ($opt, $dst) = @_;
 
        # public-inbox-index defaults to quiet, -xcpdb and -compact do not
        if (defined($opt->{quiet}) && $opt->{quiet} < 0) {
@@ -287,7 +286,8 @@ sub progress_prepare ($) {
                $opt->{1} = $null; # suitable for spawn() redirect
        } else {
                $opt->{verbose} ||= 1;
-               $opt->{-progress} = sub { print STDERR @_ };
+               $dst //= *STDERR{GLOB};
+               $opt->{-progress} = sub { print $dst @_ };
        }
 }
 
@@ -327,9 +327,9 @@ sub index_prepare ($$) {
        $opt->{batch_size} and
                $env = { XAPIAN_FLUSH_THRESHOLD => '4294967295' };
 
-       for my $k (qw(sequential_shard)) {
+       for my $k (qw(sequential-shard)) {
                my $git_key = "publicInbox.index".ucfirst($k);
-               $git_key =~ s/_([a-z])/\U$1/g;
+               $git_key =~ s/-([a-z])/\U$1/g;
                defined(my $s = $opt->{$k} // $cfg->{lc($git_key)}) or next;
                defined(my $v = $cfg->git_bool($s))
                                        or die "`$git_key=$s' not boolean\n";