unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: meta@public-inbox.org
Subject: [PATCH] mda: do not auto-create Xapian indices
Date: Tue, 4 Jun 2024 22:25:20 +0000	[thread overview]
Message-ID: <20240604222520.M507257@dcvr> (raw)
In-Reply-To: <87sexszk6s.fsf@meer.lwn.net>

Jonathan Corbet <corbet@lwn.net> wrote:
> Eric Wong <e@80x24.org> writes:
> > -mda does the detection, too, just every time.  I haven't used
> > it much with -extindex but I think it there's tests for it so it works...
> 
> Interesting...for me it recreates the 0/1/2 directories unless I edit
> the config file explicitly.

Oops, yeah, that's a bug.  -learn did it right, but not -mda
This should fix it:

-------8<------
Subject: [PATCH] mda: do not auto-create Xapian indices

As with -learn, -mda now detects indexlevel=basic without an
explicit config setting for inboxes which only have SQLite
files.  Omitting indexlevel=basic in the config file allows
users to reduce configuration file size (and RAM usage).

We'll also ensure completely unindexed v1 inboxes can stay
unindexed despite the default being indexlevel=full.
---
 script/public-inbox-mda |  1 +
 t/mda.t                 | 30 ++++++++++++++++++++++++++++++
 t/v2mda.t               | 14 ++++++++++++++
 3 files changed, 45 insertions(+)

diff --git a/script/public-inbox-mda b/script/public-inbox-mda
index b463b07b..74202912 100755
--- a/script/public-inbox-mda
+++ b/script/public-inbox-mda
@@ -72,6 +72,7 @@ if (!scalar(@$dests)) {
 my $err;
 @$dests = grep {
 	my $ibx = PublicInbox::InboxWritable->new($_);
+	$ibx->{indexlevel} = $ibx->detect_indexlevel;
 	eval { $ibx->assert_usable_dir };
 	if ($@) {
 		warn $@;
diff --git a/t/mda.t b/t/mda.t
index 1d9e237b..51aae231 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -396,6 +396,36 @@ EOM
 	@xap = grep(!m!/over\.sqlite3!,
 			glob("$maindir/public-inbox/xapian*/*"));
 	is_deeply(\@xap, [], 'no Xapian files created by -learn');
+
+	$in = <<'EOM';
+From: a@example.com
+To: updated-address@example.com
+Subject: basic message for mda
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Message-ID: <basic-for-mda@example>
+
+basic
+EOM
+	local $ENV{ORIGINAL_RECIPIENT} = $addr;
+	ok run_script(['-mda'], undef, $rdr), '-mda for basic';
+	@xap = grep(!m!/over\.sqlite3!,
+			glob("$maindir/public-inbox/xapian*/*"));
+	is_deeply \@xap, [], 'no Xapian files created by -mda';
+
+	# try ensure completely unindexed v1 stays unindexed
+	remove_tree "$maindir/public-inbox";
+	$in = <<'EOM';
+From: a@example.com
+To: updated-address@example.com
+Subject: unnidexed message for mda
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Message-ID: <unindexed-for-mda@example>
+
+unindexed
+EOM
+
+	ok run_script(['-mda'], undef, $rdr), '-mda for unindexed';
+	ok !-e "$maindir/public-inbox", 'no v1 index created by default';
 };
 
 done_testing();
diff --git a/t/v2mda.t b/t/v2mda.t
index b7d177b2..cecc9722 100644
--- a/t/v2mda.t
+++ b/t/v2mda.t
@@ -119,6 +119,20 @@ EOM
 	ok($smsg, 'ham message learned w/ indexlevel=basic');
 	@shards = grep(m!/[0-9]+\z!, glob("$ibx->{inboxdir}/xap*/*"));
 	is_deeply(\@shards, [], 'not converted to medium/full after learn');
+
+	$rdr->{0} = \<<'EOM';
+From: a@example.com
+To: test@example.com
+Subject: this is a message for -mda to stay basic
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Message-ID: <mda-stays-basic@example>
+
+yum
+EOM
+	ok run_script(['-mda'], undef, $rdr), '-learn runs on basic'
+		or diag $err;
+	@shards = grep m!/[0-9]+\z!, glob("$ibx->{inboxdir}/xap*/*");
+	is_deeply \@shards, [], 'not converted to medium/full after -mda';
 }
 
 done_testing();

      reply	other threads:[~2024-06-04 22:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 15:59 Switching to extindex Jonathan Corbet
2024-06-04 17:07 ` Eric Wong
2024-06-04 17:18   ` Jonathan Corbet
2024-06-04 17:24     ` Eric Wong
2024-06-04 17:34       ` Jonathan Corbet
2024-06-04 22:25         ` 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=20240604222520.M507257@dcvr \
    --to=e@80x24.org \
    --cc=corbet@lwn.net \
    --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.
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).