From: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 4/5] www: rework query responses to avoid COUNT in SQLite
Date: Mon, 2 Apr 2018 00:04:55 +0000 [thread overview]
Message-ID: <20180402000456.13446-5-e@80x24.org> (raw)
In-Reply-To: <20180402000456.13446-1-e@80x24.org>
In many cases, we do not care about the total number of
messages. It's a rather expensive operation in SQLite
(Xapian only provides an estimate).
For LKML, this brings top-level /$INBOX/ loading time from
~375ms to around 60ms on my system. Days ago, this operation
was taking 800-900ms(!) for me before introducing the SQLite
overview DB.
---
lib/PublicInbox/Feed.pm | 11 +++----
lib/PublicInbox/Mbox.pm | 12 +++----
lib/PublicInbox/Over.pm | 8 +++--
lib/PublicInbox/Search.pm | 15 ++++++---
lib/PublicInbox/View.pm | 17 ++++------
t/altid.t | 9 +++---
t/convert-compact.t | 6 ++--
t/over.t | 6 ++--
t/search-thr-index.t | 4 +--
t/search.t | 80 +++++++++++++++++++++++------------------------
t/v2-add-remove-add.t | 6 ++--
t/v2mda.t | 4 +--
t/v2writable.t | 2 +-
t/watch_maildir_v2.t | 26 +++++++--------
14 files changed, 104 insertions(+), 102 deletions(-)
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 2f59f8c..ff20d7f 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -27,14 +27,13 @@ sub generate {
sub generate_thread_atom {
my ($ctx) = @_;
my $mid = $ctx->{mid};
- my $res = $ctx->{srch}->get_thread($mid);
- return _no_thread() unless $res->{total};
+ my $msgs = $ctx->{srch}->get_thread($mid);
+ return _no_thread() unless @$msgs;
my $ibx = $ctx->{-inbox};
my $html_url = $ibx->base_url($ctx->{env});
$html_url .= PublicInbox::Hval->new_msgid($mid)->{href};
$ctx->{-html_url} = $html_url;
- my $msgs = $res->{msgs};
PublicInbox::WwwAtomStream->response($ctx, 200, sub {
while (my $smsg = shift @$msgs) {
$ibx->smsg_mime($smsg) and return $smsg;
@@ -114,10 +113,10 @@ sub recent_msgs {
my $o = $qp ? $qp->{o} : 0;
$o += 0;
$o = 0 if $o < 0;
- my $res = $ibx->recent({ limit => $max, offset => $o });
+ my $msgs = $ibx->recent({ limit => $max, offset => $o });
my $next = $o + $max;
- $ctx->{next_page} = "o=$next" if $res->{total} >= $next;
- return $res->{msgs};
+ $ctx->{next_page} = "o=$next" if scalar(@$msgs) == $max;
+ return $msgs;
}
my $hex = '[a-f0-9]';
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 1b68f02..05de6be 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -217,12 +217,12 @@ sub set_filename ($$) {
sub getline {
my ($self) = @_;
my $ctx = $self->{ctx} or return;
- my $res;
my $ibx = $ctx->{-inbox};
my $gz = $self->{gz};
+ my $msgs = $self->{msgs};
do {
# work on existing result set
- while (defined(my $smsg = shift @{$self->{msgs}})) {
+ while (defined(my $smsg = shift @$msgs)) {
my $msg = eval { $ibx->msg_by_smsg($smsg) } or next;
$msg = Email::Simple->new($msg);
$gz->write(PublicInbox::Mbox::msg_str($ctx, $msg,
@@ -247,11 +247,9 @@ sub getline {
}
# refill result set
- $res = $self->{cb}->($self->{opts});
- $self->{msgs} = $res->{msgs};
- $res = scalar @{$self->{msgs}};
- $self->{opts}->{offset} += $res;
- } while ($res);
+ $msgs = $self->{msgs} = $self->{cb}->($self->{opts});
+ $self->{opts}->{offset} += scalar @$msgs;
+ } while (@$msgs);
$gz->close;
delete $self->{ctx};
${delete $self->{buf}};
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index cf7a884..c74072a 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -88,10 +88,12 @@ LIMIT 1
SELECT * $cond
ORDER BY ts ASC
+ return $msgs unless wantarray;
+
my $nr = $dbh->selectrow_array(<<"", undef, $tid, $sid);
SELECT COUNT(num) $cond
- { total => $nr, msgs => $msgs };
+ ($nr, $msgs);
}
sub recent {
@@ -100,10 +102,12 @@ sub recent {
SELECT * FROM over WHERE num > 0
ORDER BY ts DESC
+ return $msgs unless wantarray;
+
my $nr = $self->{dbh}->selectrow_array(<<'');
SELECT COUNT(num) FROM over WHERE num > 0
- { total => $nr, msgs => $msgs };
+ ($nr, $msgs);
}
sub get_art {
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 9125124..84c0a22 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -185,10 +185,16 @@ sub get_thread {
sub retry_reopen {
my ($self, $cb) = @_;
- my $ret;
for my $i (1..10) {
- eval { $ret = $cb->() };
- return $ret unless $@;
+ if (wantarray) {
+ my @ret;
+ eval { @ret = $cb->() };
+ return @ret unless $@;
+ } else {
+ my $ret;
+ eval { $ret = $cb->() };
+ return $ret unless $@;
+ }
# Exception: The revision being read has been discarded -
# you should call Xapian::Database::reopen()
if (ref($@) eq 'Search::Xapian::DatabaseModifiedError') {
@@ -226,8 +232,9 @@ sub _enquire_once {
my @msgs = map {
PublicInbox::SearchMsg->load_doc($_->get_document);
} $mset->items;
+ return \@msgs unless wantarray;
- { total => $mset->get_matches_estimated, msgs => \@msgs }
+ ($mset->get_matches_estimated, \@msgs)
}
# read-write
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 8ac405f..cad90a7 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -408,9 +408,7 @@ sub thread_html {
my ($ctx) = @_;
my $mid = $ctx->{mid};
my $srch = $ctx->{srch};
- my $sres = $srch->get_thread($mid);
- my $msgs = $sres->{msgs};
- my $nr = $sres->{total};
+ my ($nr, $msgs) = $srch->get_thread($mid);
return missing_thread($ctx) if $nr == 0;
my $skel = '<hr><pre>';
$skel .= $nr == 1 ? 'only message in thread' : 'end of thread';
@@ -649,8 +647,7 @@ sub thread_skel {
my ($dst, $ctx, $hdr, $tpfx) = @_;
my $srch = $ctx->{srch};
my $mid = mids($hdr)->[0];
- my $sres = $srch->get_thread($mid);
- my $nr = $sres->{total};
+ my ($nr, $msgs) = $srch->get_thread($mid);
my $expand = qq(expand[<a\nhref="${tpfx}T/#u">flat</a>) .
qq(|<a\nhref="${tpfx}t/#u">nested</a>] ) .
qq(<a\nhref="${tpfx}t.mbox.gz">mbox.gz</a> ) .
@@ -680,12 +677,11 @@ sub thread_skel {
$ctx->{prev_attr} = '';
$ctx->{prev_level} = 0;
$ctx->{dst} = $dst;
- $sres = $sres->{msgs};
# reduce hash lookups in skel_dump
my $ibx = $ctx->{-inbox};
$ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
- walk_thread(thread_results($ctx, $sres), $ctx, *skel_dump);
+ walk_thread(thread_results($ctx, $msgs), $ctx, *skel_dump);
$ctx->{parent_msg} = $parent;
}
@@ -1066,11 +1062,10 @@ sub index_topics {
$ctx->{order} = [];
my $srch = $ctx->{srch};
- my $sres = $ctx->{-inbox}->recent({offset => $off, limit => 200 });
- $sres = $sres->{msgs};
- my $nr = scalar @$sres;
+ my $msgs = $ctx->{-inbox}->recent({offset => $off, limit => 200 });
+ my $nr = scalar @$msgs;
if ($nr) {
- walk_thread(thread_results($ctx, $sres), $ctx, *acc_topic);
+ walk_thread(thread_results($ctx, $msgs), $ctx, *acc_topic);
}
$ctx->{-next_o} = $off + $nr;
$ctx->{-cur_o} = $off;
diff --git a/t/altid.t b/t/altid.t
index 0f3b86c..d4f6152 100644
--- a/t/altid.t
+++ b/t/altid.t
@@ -50,12 +50,11 @@ my $altid = [ "serial:gmane:file=$alt_file" ];
{
my $ro = PublicInbox::Search->new($git_dir, $altid);
- my $res = $ro->query("gmane:1234");
- is($res->{total}, 1, 'got one match');
- is($res->{msgs}->[0]->mid, 'a@example.com');
+ my $msgs = $ro->query("gmane:1234");
+ is_deeply([map { $_->mid } @$msgs], ['a@example.com'], 'got one match');
- $res = $ro->query("gmane:666");
- is($res->{total}, 0, 'body did NOT match');
+ $msgs = $ro->query("gmane:666");
+ is_deeply([], $msgs, 'body did NOT match');
};
{
diff --git a/t/convert-compact.t b/t/convert-compact.t
index 92a6a9c..e2ba40a 100644
--- a/t/convert-compact.t
+++ b/t/convert-compact.t
@@ -99,8 +99,8 @@ foreach (@xdir) {
is($st[2] & 07777, -f _ ? 0444 : 0755,
'sharedRepository respected after v2 compact');
}
-my $res = $ibx->recent({limit => 1000});
-is($res->{msgs}->[0]->{mid}, 'a-mid@b', 'message exists in history');
-is(scalar @{$res->{msgs}}, 1, 'only one message in history');
+my $msgs = $ibx->recent({limit => 1000});
+is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
+is(scalar @$msgs, 1, 'only one message in history');
done_testing();
diff --git a/t/over.t b/t/over.t
index bfe331e..2a7e8d1 100644
--- a/t/over.t
+++ b/t/over.t
@@ -40,7 +40,7 @@ my $ddd = compress('');
foreach my $s ('', undef) {
$over->add_over([0, 98, [ 'a' ], [], $s, $ddd]);
$over->add_over([0, 99, [ 'b' ], [], $s, $ddd]);
- my $msgs = [ map { $_->{num} } @{$over->get_thread('a')->{msgs}} ];
+ my $msgs = [ map { $_->{num} } @{$over->get_thread('a')} ];
is_deeply([98], $msgs,
'messages not linked by empty subject');
}
@@ -48,13 +48,13 @@ foreach my $s ('', undef) {
$over->add_over([0, 98, [ 'a' ], [], 's', $ddd]);
$over->add_over([0, 99, [ 'b' ], [], 's', $ddd]);
foreach my $mid (qw(a b)) {
- my $msgs = [ map { $_->{num} } @{$over->get_thread('a')->{msgs}} ];
+ my $msgs = [ map { $_->{num} } @{$over->get_thread('a')} ];
is_deeply([98, 99], $msgs, 'linked messages by subject');
}
$over->add_over([0, 98, [ 'a' ], [], 's', $ddd]);
$over->add_over([0, 99, [ 'b' ], ['a'], 'diff', $ddd]);
foreach my $mid (qw(a b)) {
- my $msgs = [ map { $_->{num} } @{$over->get_thread($mid)->{msgs}} ];
+ my $msgs = [ map { $_->{num} } @{$over->get_thread($mid)} ];
is_deeply([98, 99], $msgs, "linked messages by Message-ID: <$mid>");
}
diff --git a/t/search-thr-index.t b/t/search-thr-index.t
index 3ddef80..2aa97bf 100644
--- a/t/search-thr-index.t
+++ b/t/search-thr-index.t
@@ -49,8 +49,8 @@ foreach (reverse split(/\n\n/, $data)) {
my $prev;
foreach my $mid (@mids) {
- my $res = $rw->{over}->get_thread($mid);
- is(3, $res->{total}, "got all messages from $mid");
+ my $msgs = $rw->{over}->get_thread($mid);
+ is(3, scalar(@$msgs), "got all messages from $mid");
}
$rw->commit_txn_lazy;
diff --git a/t/search.t b/t/search.t
index 51adb9f..c9bef71 100644
--- a/t/search.t
+++ b/t/search.t
@@ -82,8 +82,8 @@ my $rw_commit = sub {
}
sub filter_mids {
- my ($res) = @_;
- sort(map { $_->mid } @{$res->{msgs}});
+ my ($msgs) = @_;
+ sort(map { $_->mid } @$msgs);
}
{
@@ -106,12 +106,12 @@ sub filter_mids {
is_deeply(\@res, \@exp, 'got expected results for s:"" match');
$res = $ro->query('s:"Hello world"', {limit => 1});
- is(scalar @{$res->{msgs}}, 1, "limit works");
- my $first = $res->{msgs}->[0];
+ is(scalar @$res, 1, "limit works");
+ my $first = $res->[0];
$res = $ro->query('s:"Hello world"', {offset => 1});
- is(scalar @{$res->{msgs}}, 1, "offset works");
- my $second = $res->{msgs}->[0];
+ is(scalar @$res, 1, "offset works");
+ my $second = $res->[0];
isnt($first, $second, "offset returned different result from limit");
}
@@ -147,7 +147,7 @@ sub filter_mids {
my $ghost_id = $rw->add_message($was_ghost);
is($ghost_id, int($ghost_id), "ghost_id is an integer: $ghost_id");
- my $msgs = $rw->{over}->get_thread('ghost-message@s')->{msgs};
+ my $msgs = $rw->{over}->get_thread('ghost-message@s');
is(scalar(@$msgs), 2, 'got both messages in ghost thread');
foreach (qw(sid tid)) {
is($msgs->[0]->{$_}, $msgs->[1]->{$_}, "{$_} match");
@@ -169,7 +169,7 @@ sub filter_mids {
# body
$res = $ro->query('goodbye');
- is($res->{msgs}->[0]->mid, 'last@s', 'got goodbye message body');
+ is($res->[0]->mid, 'last@s', 'got goodbye message body');
}
# long message-id
@@ -215,7 +215,7 @@ sub filter_mids {
$rw_commit->();
$ro->reopen;
my $t = $ro->get_thread('root@s');
- is($t->{total}, 4, "got all 4 mesages in thread");
+ is(scalar(@$t), 4, "got all 4 mesages in thread");
my @exp = sort($long_reply_mid, 'root@s', 'last@s', $long_mid);
@res = filter_mids($t);
is_deeply(\@res, \@exp, "get_thread works");
@@ -244,13 +244,13 @@ sub filter_mids {
],
body => "theatre\nfade\n"));
my $res = $rw->query("theatre");
- is($res->{total}, 2, "got both matches");
- is($res->{msgs}->[0]->mid, 'nquote@a', "non-quoted scores higher");
- is($res->{msgs}->[1]->mid, 'quote@a', "quoted result still returned");
+ is(scalar(@$res), 2, "got both matches");
+ is($res->[0]->mid, 'nquote@a', "non-quoted scores higher");
+ is($res->[1]->mid, 'quote@a', "quoted result still returned");
$res = $rw->query("illusions");
- is($res->{total}, 1, "got a match for quoted text");
- is($res->{msgs}->[0]->mid, 'quote@a',
+ is(scalar(@$res), 1, "got a match for quoted text");
+ is($res->[0]->mid, 'quote@a',
"quoted result returned if nothing else");
}
@@ -293,34 +293,34 @@ sub filter_mids {
}
{
- my $res = $ro->query('d:19931002..20101002');
- ok(scalar @{$res->{msgs}} > 0, 'got results within range');
- $res = $ro->query('d:20101003..');
- is(scalar @{$res->{msgs}}, 0, 'nothing after 20101003');
- $res = $ro->query('d:..19931001');
- is(scalar @{$res->{msgs}}, 0, 'nothing before 19931001');
+ my $msgs = $ro->query('d:19931002..20101002');
+ ok(scalar(@$msgs) > 0, 'got results within range');
+ $msgs = $ro->query('d:20101003..');
+ is(scalar(@$msgs), 0, 'nothing after 20101003');
+ $msgs = $ro->query('d:..19931001');
+ is(scalar(@$msgs), 0, 'nothing before 19931001');
}
# names and addresses
{
my $res = $ro->query('t:list@example.com');
- is(scalar @{$res->{msgs}}, 6, 'searched To: successfully');
- foreach my $smsg (@{$res->{msgs}}) {
+ is(scalar @$res, 6, 'searched To: successfully');
+ foreach my $smsg (@$res) {
like($smsg->to, qr/\blist\@example\.com\b/, 'to appears');
}
$res = $ro->query('tc:list@example.com');
- is(scalar @{$res->{msgs}}, 6, 'searched To+Cc: successfully');
- foreach my $smsg (@{$res->{msgs}}) {
+ is(scalar @$res, 6, 'searched To+Cc: successfully');
+ foreach my $smsg (@$res) {
my $tocc = join("\n", $smsg->to, $smsg->cc);
like($tocc, qr/\blist\@example\.com\b/, 'tocc appears');
}
foreach my $pfx ('tcf:', 'c:') {
$res = $ro->query($pfx . 'foo@example.com');
- is(scalar @{$res->{msgs}}, 1,
+ is(scalar @$res, 1,
"searched $pfx successfully for Cc:");
- foreach my $smsg (@{$res->{msgs}}) {
+ foreach my $smsg (@$res) {
like($smsg->cc, qr/\bfoo\@example\.com\b/,
'cc appears');
}
@@ -328,9 +328,9 @@ sub filter_mids {
foreach my $pfx ('', 'tcf:', 'f:') {
$res = $ro->query($pfx . 'Laggy');
- is(scalar @{$res->{msgs}}, 1,
+ is(scalar(@$res), 1,
"searched $pfx successfully for From:");
- foreach my $smsg (@{$res->{msgs}}) {
+ foreach my $smsg (@$res) {
like($smsg->from, qr/Laggy Sender/,
"From appears with $pfx");
}
@@ -341,23 +341,23 @@ sub filter_mids {
$rw_commit->();
$ro->reopen;
my $res = $ro->query('b:hello');
- is(scalar @{$res->{msgs}}, 0, 'no match on body search only');
+ is(scalar(@$res), 0, 'no match on body search only');
$res = $ro->query('bs:smith');
- is(scalar @{$res->{msgs}}, 0,
+ is(scalar(@$res), 0,
'no match on body+subject search for From');
$res = $ro->query('q:theatre');
- is(scalar @{$res->{msgs}}, 1, 'only one quoted body');
- like($res->{msgs}->[0]->from, qr/\AQuoter/, 'got quoted body');
+ is(scalar(@$res), 1, 'only one quoted body');
+ like($res->[0]->from, qr/\AQuoter/, 'got quoted body');
$res = $ro->query('nq:theatre');
- is(scalar @{$res->{msgs}}, 1, 'only one non-quoted body');
- like($res->{msgs}->[0]->from, qr/\ANon-Quoter/, 'got non-quoted body');
+ is(scalar @$res, 1, 'only one non-quoted body');
+ like($res->[0]->from, qr/\ANon-Quoter/, 'got non-quoted body');
foreach my $pfx (qw(b: bs:)) {
$res = $ro->query($pfx . 'theatre');
- is(scalar @{$res->{msgs}}, 2, "searched both bodies for $pfx");
- like($res->{msgs}->[0]->from, qr/\ANon-Quoter/,
+ is(scalar @$res, 2, "searched both bodies for $pfx");
+ like($res->[0]->from, qr/\ANon-Quoter/,
"non-quoter first for $pfx");
}
}
@@ -396,13 +396,13 @@ sub filter_mids {
$rw_commit->();
$ro->reopen;
my $n = $ro->query('n:attached_fart.txt');
- is(scalar @{$n->{msgs}}, 1, 'got result for n:');
+ is(scalar @$n, 1, 'got result for n:');
my $res = $ro->query('part_deux.txt');
- is(scalar @{$res->{msgs}}, 1, 'got result without n:');
- is($n->{msgs}->[0]->mid, $res->{msgs}->[0]->mid,
+ is(scalar @$res, 1, 'got result without n:');
+ is($n->[0]->mid, $res->[0]->mid,
'same result with and without');
my $txt = $ro->query('"inside another"');
- is($txt->{msgs}->[0]->mid, $res->{msgs}->[0]->mid,
+ is($txt->[0]->mid, $res->[0]->mid,
'search inside text attachments works');
}
$rw->commit_txn_lazy;
diff --git a/t/v2-add-remove-add.t b/t/v2-add-remove-add.t
index b6c5887..c8d12d3 100644
--- a/t/v2-add-remove-add.t
+++ b/t/v2-add-remove-add.t
@@ -35,8 +35,8 @@ ok($im->add($mime), 'message added');
ok($im->remove($mime), 'message added');
ok($im->add($mime), 'message added again');
$im->done;
-my $res = $ibx->recent({limit => 1000});
-is($res->{msgs}->[0]->{mid}, 'a-mid@b', 'message exists in history');
-is(scalar @{$res->{msgs}}, 1, 'only one message in history');
+my $msgs = $ibx->recent({limit => 1000});
+is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
+is(scalar @$msgs, 1, 'only one message in history');
done_testing();
diff --git a/t/v2mda.t b/t/v2mda.t
index be27ca0..ca1bb09 100644
--- a/t/v2mda.t
+++ b/t/v2mda.t
@@ -52,8 +52,8 @@ ok(PublicInbox::Import::run_die(['public-inbox-mda'], undef, $rdr),
'mda delivered a message');
$ibx = PublicInbox::Inbox->new($ibx);
-my $res = $ibx->search->query('');
-my $saved = $ibx->smsg_mime($res->{msgs}->[0]);
+my $msgs = $ibx->search->query('');
+my $saved = $ibx->smsg_mime($msgs->[0]);
is($saved->{mime}->as_string, $mime->as_string, 'injected message');
done_testing();
diff --git a/t/v2writable.t b/t/v2writable.t
index 7e29ef7..1e8e404 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -249,7 +249,7 @@ EOF
ok($im->add($mime), 'add excessively long References');
$im->barrier;
- my $msgs = $ibx->search->reopen->get_thread('x'x244)->{msgs};
+ my $msgs = $ibx->search->reopen->get_thread('x'x244);
is(2, scalar(@$msgs), 'got both messages');
is($msgs->[0]->{mid}, 'x'x244, 'stored truncated mid');
is($msgs->[1]->{references}, '<'.('x'x244).'>', 'stored truncated ref');
diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t
index 85130e3..a76e413 100644
--- a/t/watch_maildir_v2.t
+++ b/t/watch_maildir_v2.t
@@ -50,8 +50,8 @@ ok($ibx, 'found inbox by name');
my $srch = $ibx->search;
PublicInbox::WatchMaildir->new($config)->scan('full');
-my $res = $srch->reopen->query('');
-is($res->{total}, 1, 'got one revision');
+my ($total, undef) = $srch->reopen->query('');
+is($total, 1, 'got one revision');
# my $git = PublicInbox::Git->new("$mainrepo/git/0.git");
# my @list = $git->qx(qw(rev-list refs/heads/master));
@@ -70,7 +70,7 @@ my $write_spam = sub {
$write_spam->();
is(unlink(glob("$maildir/new/*")), 1, 'unlinked old spam');
PublicInbox::WatchMaildir->new($config)->scan('full');
-is($srch->reopen->query('')->{total}, 0, 'deleted file');
+is(($srch->reopen->query(''))[0], 0, 'deleted file');
# check with scrubbing
{
@@ -80,16 +80,16 @@ the body of a message to majordomo\@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
PublicInbox::WatchMaildir->new($config)->scan('full');
- $res = $srch->reopen->query('');
- is($res->{total}, 1, 'got one file back');
- my $mref = $ibx->msg_by_smsg($res->{msgs}->[0]);
+ my ($nr, $msgs) = $srch->reopen->query('');
+ is($nr, 1, 'got one file back');
+ my $mref = $ibx->msg_by_smsg($msgs->[0]);
like($$mref, qr/something\n\z/s, 'message scrubbed on import');
is(unlink(glob("$maildir/new/*")), 1, 'unlinked spam');
$write_spam->();
PublicInbox::WatchMaildir->new($config)->scan('full');
- $res = $srch->reopen->query('');
- is($res->{total}, 0, 'inbox is empty again');
+ ($nr, $msgs) = $srch->reopen->query('');
+ is($nr, 0, 'inbox is empty again');
}
{
@@ -103,8 +103,8 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
local $SIG{__WARN__} = sub {}; # quiet spam check warning
PublicInbox::WatchMaildir->new($config)->scan('full');
}
- $res = $srch->reopen->query('');
- is($res->{total}, 0, 'inbox is still empty');
+ ($nr, $msgs) = $srch->reopen->query('');
+ is($nr, 0, 'inbox is still empty');
is(unlink(glob("$maildir/new/*")), 1);
}
@@ -116,9 +116,9 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
$config->{'publicinboxwatch.spamcheck'} = 'spamc';
PublicInbox::WatchMaildir->new($config)->scan('full');
- $res = $srch->reopen->query('');
- is($res->{total}, 1, 'inbox has one mail after spamc OK-ed a message');
- my $mref = $ibx->msg_by_smsg($res->{msgs}->[0]);
+ ($nr, $msgs) = $srch->reopen->query('');
+ is($nr, 1, 'inbox has one mail after spamc OK-ed a message');
+ my $mref = $ibx->msg_by_smsg($msgs->[0]);
like($$mref, qr/something\n\z/s, 'message scrubbed on import');
}
--
EW
next prev parent reply other threads:[~2018-04-02 0:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-02 0:04 [PATCH 0/5] v2: drop Xapian skeleton for SQLite overview DB Eric Wong (Contractor, The Linux Foundation)
2018-04-02 0:04 ` [PATCH 1/5] replace Xapian skeleton with " Eric Wong (Contractor, The Linux Foundation)
2018-04-05 8:59 ` Eric Wong
2018-04-02 0:04 ` [PATCH 2/5] v2writable: simplify barrier vs checkpoints Eric Wong (Contractor, The Linux Foundation)
2018-04-02 0:04 ` [PATCH 3/5] t/over: test empty Subject: line matching Eric Wong (Contractor, The Linux Foundation)
2018-04-02 0:04 ` Eric Wong (Contractor, The Linux Foundation) [this message]
2018-04-02 0:04 ` [PATCH 5/5] over: speedup get_thread by avoiding JOIN Eric Wong (Contractor, The Linux Foundation)
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=20180402000456.13446-5-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
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).