From: Eric Wong Date: Tue, 4 Jun 2024 22:25:20 +0000 (+0000) Subject: mda: do not auto-create Xapian indices X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b236b55180e961bdc529533ad3c374666de9dce3;p=thirdparty%2Fpublic-inbox.git 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. --- diff --git a/script/public-inbox-mda b/script/public-inbox-mda index b463b07b4..742029128 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 1d9e237ba..51aae231c 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 +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 +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 b7d177b2b..cecc97223 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: + +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();