From: Eric Wong Date: Tue, 24 Oct 2023 11:44:29 +0000 (+0000) Subject: cindex: basic inboxes are non-fatal for --associate X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5061fda82a5df67f12b0b392bdad481cc07aa283;p=thirdparty%2Fpublic-inbox.git cindex: basic inboxes are non-fatal for --associate We need to gracefully continue when a user tries to associate with --all but has basic (or completely unindexed) inboxes. --- diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index 2d1d8b223..c8e4c5915 100644 --- a/lib/PublicInbox/CodeSearchIdx.pm +++ b/lib/PublicInbox/CodeSearchIdx.pm @@ -551,12 +551,14 @@ sub dump_roots_start { sub dump_ibx { # sends to xap_helper.h my ($self, $ibx_id) = @_; my $ibx = $IBX[$ibx_id] // die "BUG: no IBX[$ibx_id]"; - my @cmd = ('dump_ibx', $ibx->isrch->xh_args, - (map { ('-A', $_) } @ASSOC_PFX), - $ibx_id, $QRY_STR); + my $ekey = $ibx->eidx_key; + my $srch = $ibx->isrch or return warn <xh_args, + (map { ('-A', $_) } @ASSOC_PFX), $ibx_id, $QRY_STR); pipe(my $r, my $w); $XHC->mkreq([$DUMP_IBX_WPIPE, $w], @cmd); - my $ekey = $ibx->eidx_key; $self->{PENDING}->{$ekey} = $TODO{associate}; PublicInbox::CidxXapHelperAux->new($r, $self, $ekey); } diff --git a/t/cindex.t b/t/cindex.t index 51317329a..c7de15054 100644 --- a/t/cindex.t +++ b/t/cindex.t @@ -198,4 +198,25 @@ SKIP: { ok(run_script([qw(-xcpdb --compact), "$tmp/ext"]), 'xcpdb compact'); }; +my $basic = create_inbox 'basic', indexlevel => 'basic', sub { + my ($im, $ibx) = @_; + $im->add(eml_load('t/plack-qp.eml')); +}; +{ + my $env = { PI_CONFIG => "$tmp/pi_config" }; + open my $fh, '>', $env->{PI_CONFIG}; + print $fh <{inboxdir} + address = basic\@example.com +EOM + close $fh; + my $cmd = [ qw(-cindex -u --all --associate -d), "$tmp/ext", + '-I', $basic->{inboxdir} ]; + my $opt = { 1 => \(my $cidx_out), 2 => \(my $cidx_err) }; + ok(run_script($cmd, $env, $opt), 'associate w/o search'); + like($cidx_err, qr/W: \Q$basic->{inboxdir}\E not indexed for search/, + 'non-Xapian-enabled inbox noted'); +} + done_testing;