diff options
author | Eric Wong <e@80x24.org> | 2023-10-24 11:44:29 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-24 20:04:29 +0000 |
commit | 5061fda82a5df67f12b0b392bdad481cc07aa283 (patch) | |
tree | 32432c663fcafe41d22877880a0734b628176737 | |
parent | 9c22e8be762a8bf8a72eb8d510bc8b3e7362f6bb (diff) | |
download | public-inbox-5061fda82a5df67f12b0b392bdad481cc07aa283.tar.gz |
We need to gracefully continue when a user tries to associate with --all but has basic (or completely unindexed) inboxes.
-rw-r--r-- | lib/PublicInbox/CodeSearchIdx.pm | 10 | ||||
-rw-r--r-- | t/cindex.t | 21 |
2 files changed, 27 insertions, 4 deletions
diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index 2d1d8b22..c8e4c591 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 <<EOM; +W: $ekey not indexed for search +EOM + my @cmd = ('dump_ibx', $srch->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); } @@ -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 <<EOM; +[publicinbox "basictest"] + inboxdir = $basic->{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; |