From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 71FD01F4BC for ; Wed, 15 May 2019 06:33:56 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/6] searchidx: do not create empty Xapian partitions for basic Date: Wed, 15 May 2019 06:33:53 +0000 Message-Id: <20190515063354.52259-6-e@80x24.org> In-Reply-To: <20190515063354.52259-1-e@80x24.org> References: <20190515063354.52259-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No point in leaving a mess of empty directories when Xapian doesn't load. --- lib/PublicInbox/SearchIdx.pm | 7 ++++++- t/indexlevels-mirror.t | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 135b5eb..f96f0d0 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 cac7050..3dd4323 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 -- EW