]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
mda: do not auto-create Xapian indices
authorEric Wong <e@80x24.org>
Tue, 4 Jun 2024 22:25:20 +0000 (22:25 +0000)
committerEric Wong <e@80x24.org>
Wed, 5 Jun 2024 22:19:44 +0000 (22:19 +0000)
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
t/mda.t
t/v2mda.t

index b463b07b4f7f22bc3eebfd78af6ab3256846a460..7420291283582402017c2dcd9bc6edf8fe27c714 100755 (executable)
@@ -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 1d9e237ba7098cae45e68210967dd8ac0dd3b027..51aae231cbd63f03ffb0542721f009641b8f92ef 100644 (file)
--- 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();
index b7d177b2b97e4afc86c1157f89ad83aee2224ad4..cecc97223889cfcbe255e1192f304140a4eab99f 100644 (file)
--- 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();