]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Admin.pm
nntp: small speed up for multi-line responses
[public-inbox.git] / lib / PublicInbox / Admin.pm
index ce720beb6b2febd1439da2e40110fb06401db00b..9d48e5ebee4131553e6442e135d7a0d642e55b58 100644 (file)
@@ -48,13 +48,14 @@ sub resolve_repo_dir {
 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 $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';
-       my $srch = $ibx->search or return $l;
-       delete $ibx->{search}; # don't leave open FD lying around
+       return $l unless $srch;
        if (my $xdb = $srch->xdb) {
                $l = 'full';
                my $m = $xdb->get_metadata('indexlevel');
@@ -65,6 +66,7 @@ sub detect_indexlevel ($) {
 $ibx->{inboxdir} has unexpected indexlevel in Xapian: $m
 
                }
+               $ibx->{-skip_docdata} = 1 if $xdb->get_metadata('skip_docdata');
        }
        $l;
 }
@@ -95,12 +97,14 @@ sub resolve_inboxes ($;$$) {
        my $min_ver = $opt->{-min_inbox_version} || 0;
        my (@old, @ibxs);
        my %dir2ibx;
+       my $all = $opt->{all} ? [] : undef;
        if ($cfg) {
                $cfg->each_inbox(sub {
                        my ($ibx) = @_;
                        my $path = abs_path($ibx->{inboxdir});
                        if (defined($path)) {
                                $dir2ibx{$path} = $ibx;
+                               push @$all, $ibx if $all;
                        } else {
                                warn <<EOF;
 W: $ibx->{name} $ibx->{inboxdir}: $!
@@ -108,10 +112,9 @@ EOF
                        }
                });
        }
-       if ($opt->{all}) {
-               my @all = values %dir2ibx;
-               @all = grep { $_->version >= $min_ver } @all;
-               push @ibxs, @all;
+       if ($all) {
+               @$all = grep { $_->version >= $min_ver } @$all;
+               @ibxs = @$all;
        } else { # directories specified on the command-line
                my $i = 0;
                my @dirs = @$argv;
@@ -129,7 +132,7 @@ EOF
                }
        }
        if (@old) {
-               die "inboxes $min_ver inboxes not supported by $0\n\t",
+               die "-V$min_ver inboxes not supported by $0\n\t",
                    join("\n\t", @old), "\n";
        }
        @ibxs;
@@ -207,6 +210,9 @@ sub index_terminate {
 sub index_inbox {
        my ($ibx, $im, $opt) = @_;
        my $jobs = delete $opt->{jobs} if $opt;
+       if (my $pr = $opt->{-progress}) {
+               $pr->("indexing $ibx->{inboxdir} ...\n");
+       }
        local %SIG = %SIG;
        setup_signals(\&index_terminate, $ibx);
        if (ref($ibx) && $ibx->version == 2) {
@@ -219,9 +225,9 @@ sub index_inbox {
                                $v2w->{parallel} = 0;
                        } else {
                                my $n = $v2w->{shards};
-                               if ($jobs != ($n + 1) && !$opt->{reshard}) {
+                               if ($jobs < ($n + 1) && !$opt->{reshard}) {
                                        warn
-"Unable to respect --jobs=$jobs, inbox was created with $n shards\n";
+"Unable to respect --jobs=$jobs on index, inbox was created with $n shards\n";
                                }
                        }
                }