diff options
author | Eric Wong <e@80x24.org> | 2019-05-15 01:18:10 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-05-15 05:54:18 +0000 |
commit | b5c64fc01d3e7ca6243fdd8b811b6291bdb12235 (patch) | |
tree | 056423983243b90b4f46c875e5e335e856932647 | |
parent | 0b1de991a099b5e8b9a9e3e85b5eaaacc9362dbb (diff) | |
download | public-inbox-b5c64fc01d3e7ca6243fdd8b811b6291bdb12235.tar.gz |
No point in leaving a mess of empty directories when Xapian doesn't load.
-rw-r--r-- | lib/PublicInbox/SearchIdx.pm | 7 | ||||
-rw-r--r-- | t/indexlevels-mirror.t | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 135b5eb9..f96f0d03 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -110,7 +110,12 @@ sub _xdb_acquire { if ($self->{creat}) { require File::Path; $self->lock_acquire; - File::Path::mkpath($dir); + + # don't create empty Xapian directories if we don't need Xapian + my $is_part = defined($self->{partition}); + if (!$is_part || ($is_part && need_xapian($self))) { + File::Path::mkpath($dir); + } } return unless defined $flag; $self->{xdb} = Search::Xapian::WritableDatabase->new($dir, $flag); diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t index cac7050b..3dd43238 100644 --- a/t/indexlevels-mirror.t +++ b/t/indexlevels-mirror.t @@ -116,6 +116,11 @@ sub import_index_incremental { is($nr, 1, '2nd message gone from mirror'); is_deeply([map { $_->{mid} } @$msgs], ['m@1'], 'message unavailable in mirror'); + + if ($v == 2 && $level eq 'basic') { + is_deeply([glob("$ibx->{mainrepo}/xap*/?/")], [], + 'no Xapian partition directories for v2 basic'); + } } # we can probably cull some other tests and put full/medium tests, here |