user/dev discussion of public-inbox itself
 help / color / Atom feed
From: Eric Wong <e@80x24.org>
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> (raw)
In-Reply-To: <20190515063354.52259-1-e@80x24.org>

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


  parent reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15  6:33 [PATCH 0/6] make Search::Xapian optional for v2, NNTP, etc Eric Wong
2019-05-15  6:33 ` [PATCH 1/6] inbox: add ->over method to ease access Eric Wong
2019-05-15  6:33 ` [PATCH 2/6] nntp: use Inbox->over directly Eric Wong
2019-05-15  6:33 ` [PATCH 3/6] www: use Inbox->over where appropriate Eric Wong
2019-05-15  6:33 ` [PATCH 4/6] lazy load Xapian and make it optional for v2 Eric Wong
2019-05-15  6:33 ` Eric Wong [this message]
2019-05-15  6:33 ` [PATCH 6/6] admin: improve warnings and errors for missing modules Eric Wong
2019-05-22  0:35 ` [PATCH 0/6] make Search::Xapian optional for v2, NNTP, etc Eric Wong

Reply instructions:

You may reply publically 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=20190515063354.52259-6-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

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox