about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-08-08 01:14:17 +0000
committerEric Wong <e@80x24.org>2021-08-08 01:17:26 +0000
commitc951a8ee25edd8489ce127acd8b2caf54e6dad6f (patch)
treed1736b0ee8c6b705529e055b1d90e52ffde89fb6
parent6bcc4f94adad46240da102c3e36a2b6df8e7ce38 (diff)
downloadpublic-inbox-c951a8ee25edd8489ce127acd8b2caf54e6dad6f.tar.gz
Xapian bindings may not be installed or be out-of-date w.r.t. the
Perl version, improve the visibility of errors in those cases.
Cleanup and drop some redundant checks while we're at it.

Cc: "Toke Høiland-Jørgensen" <toke@toke.dk>
Link: https://public-inbox.org/meta/87k0ky5mbd.fsf@toke.dk/
-rw-r--r--lib/PublicInbox/SearchIdx.pm6
-rw-r--r--lib/PublicInbox/Xapcmd.pm2
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index f4f3ba34..5b0e4458 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -94,7 +94,7 @@ sub need_xapian ($) { $_[0]->{indexlevel} =~ $xapianlevels }
 sub idx_release {
         my ($self, $wake) = @_;
         if (need_xapian($self)) {
-                my $xdb = delete $self->{xdb} or croak 'not acquired';
+                my $xdb = delete $self->{xdb} or croak '{xdb} not acquired';
                 $xdb->close;
         }
         $self->lock_release($wake) if $self->{creat};
@@ -103,7 +103,7 @@ sub idx_release {
 
 sub load_xapian_writable () {
         return 1 if $X->{WritableDatabase};
-        PublicInbox::Search::load_xapian() or return;
+        PublicInbox::Search::load_xapian() or die "failed to load Xapian: $@\n";
         my $xap = $PublicInbox::Search::Xap;
         for (qw(Document TermGenerator WritableDatabase)) {
                 $X->{$_} = $xap.'::'.$_;
@@ -783,7 +783,7 @@ sub v1_checkpoint ($$;$) {
         ${$sync->{max}} = $self->{batch_bytes};
 
         $self->{mm}->{dbh}->commit;
-        my $xdb = need_xapian($self) ? $self->{xdb} : undef;
+        my $xdb = $self->{xdb};
         if ($newest && $xdb) {
                 my $cur = $xdb->get_metadata('last_commit');
                 if (need_update($self, $cur, $newest)) {
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index e37eece5..8b8958c7 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -406,7 +406,7 @@ sub cpdb ($$) { # cb_spawn callback
         my $new = $newdir->dirname;
         my ($src, $cur_shard);
         my $reshard;
-        PublicInbox::SearchIdx::load_xapian_writable() or die;
+        PublicInbox::SearchIdx::load_xapian_writable();
         my $XapianDatabase = $PublicInbox::Search::X{Database};
         if (ref($old) eq 'ARRAY') {
                 ($cur_shard) = ($new =~ m!(?:xap|ei)[0-9]+/([0-9]+)\b!);