From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/3] cindex: basic inboxes are non-fatal for --associate
Date: Tue, 24 Oct 2023 11:44:29 +0000 [thread overview]
Message-ID: <20231024114429.2998844-4-e@80x24.org> (raw)
In-Reply-To: <20231024114429.2998844-1-e@80x24.org>
We need to gracefully continue when a user tries to associate
with --all but has basic (or completely unindexed) inboxes.
---
lib/PublicInbox/CodeSearchIdx.pm | 10 ++++++----
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);
}
diff --git a/t/cindex.t b/t/cindex.t
index 51317329..c7de1505 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 <<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;
prev parent reply other threads:[~2023-10-24 11:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 11:44 [PATCH 0/3] cindex: handle usage errors gracefully Eric Wong
2023-10-24 11:44 ` [PATCH 1/3] cindex: --associate fails when no inboxes are given Eric Wong
2023-10-24 11:44 ` [PATCH 2/3] t/cindex: use autodie Eric Wong
2023-10-24 11:44 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231024114429.2998844-4-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).