about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-18 04:30:32 -0600
committerEric Wong <e@80x24.org>2021-01-18 21:20:32 +0000
commit935f837e759f03ed48d369ab97517b8b03662ba3 (patch)
tree861a7c99e9d436c551ccd2bebb5ceee2e3b9c5c8 /t
parent51191d611e918ff3ef6e9ce8ee52ba7b2cd2144c (diff)
downloadpublic-inbox-935f837e759f03ed48d369ab97517b8b03662ba3.tar.gz
Instead of optimizing our own performance, this optimizes
our data to reduce work done by the MUA consumer.

Maildir and mbox destinations no longer support any notion of
the IMAP \Recent flag.  JMAP has no functioning \Recent
equivalent, and neither do we.

In practice, having MUAs (e.g. mutt) clear the \Recent flag when
committing changes to the mbox is expensive: it creates a
rename(2) storm with Maildir and overwrites the entire mbox.

For mboxcl2 (and mboxcl), we'll further optimize mutt behavior
by setting the Lines: header in addition to Content-Length.

With these changes, mutt exits instantaneously on mboxcl2,
mboxcl, and Maildirs generated by "lei q".
Diffstat (limited to 't')
-rw-r--r--t/lei_to_mail.t16
-rw-r--r--t/mbox_reader.t2
2 files changed, 13 insertions, 5 deletions
diff --git a/t/lei_to_mail.t b/t/lei_to_mail.t
index 083e0df4..e5ac8eac 100644
--- a/t/lei_to_mail.t
+++ b/t/lei_to_mail.t
@@ -25,7 +25,7 @@ for my $mbox (@MBOX) {
         my $s = $cb->(PublicInbox::Eml->new($from), $kw);
         is(substr($$s, -1, 1), "\n", "trailing LF in normal $mbox");
         my $eml = PublicInbox::Eml->new($s);
-        is($eml->header('Status'), 'R', "Status: set by $m");
+        is($eml->header('Status'), 'OR', "Status: set by $m");
         is($eml->header('X-Status'), 'AF', "X-Status: set by $m");
         if ($mbox eq 'mboxcl2') {
                 like($eml->body_raw, qr/^From /, "From not escaped $m");
@@ -170,6 +170,12 @@ for my $zsfx (qw(gz bz2 xz)) { # XXX should we support zst, zz, lzo, lzma?
         }
 }
 
+my $as_orig = sub {
+        my ($eml) = @_;
+        $eml->header_set('Status');
+        $eml->as_string;
+};
+
 unlink $fn or BAIL_OUT $!;
 if ('default deduplication uses content_hash') {
         my $wcb = $wcb_get->('mboxo', $fn);
@@ -177,7 +183,7 @@ if ('default deduplication uses content_hash') {
         undef $wcb; # undef to commit changes
         my $cmp = '';
         open my $fh, '<', $fn or BAIL_OUT $!;
-        PublicInbox::MboxReader->mboxo($fh, sub { $cmp .= shift->as_string });
+        PublicInbox::MboxReader->mboxo($fh, sub { $cmp .= $as_orig->(@_) });
         is($cmp, $buf, 'only one message written');
 
         local $lei->{opt} = { augment => 1 };
@@ -186,7 +192,7 @@ if ('default deduplication uses content_hash') {
         undef $wcb; # undef to commit changes
         open $fh, '<', $fn or BAIL_OUT $!;
         my @x;
-        PublicInbox::MboxReader->mboxo($fh, sub { push @x, shift->as_string });
+        PublicInbox::MboxReader->mboxo($fh, sub { push @x, $as_orig->(@_) });
         is(scalar(@x), 2, 'augmented mboxo');
         is($x[0], $cmp, 'original message preserved');
         is($x[1], $buf . "\nx\n", 'new message appended');
@@ -200,7 +206,7 @@ if ('default deduplication uses content_hash') {
         undef $wcb; # commit
         seek($tmp, 0, SEEK_SET) or BAIL_OUT $!;
         my $cmp = '';
-        PublicInbox::MboxReader->mboxrd($tmp, sub { $cmp .= shift->as_string });
+        PublicInbox::MboxReader->mboxrd($tmp, sub { $cmp .= $as_orig->(@_) });
         is($cmp, $buf, 'message written to stdout');
 }
 
@@ -213,7 +219,7 @@ SKIP: { # FIFO support
         $wcb->(\(my $x = $buf), 'deadbeef', []);
         undef $wcb; # commit
         my $cmp = '';
-        PublicInbox::MboxReader->mboxo($cat, sub { $cmp .= shift->as_string });
+        PublicInbox::MboxReader->mboxo($cat, sub { $cmp .= $as_orig->(@_) });
         is($cmp, $buf, 'message written to FIFO');
 }
 
diff --git a/t/mbox_reader.t b/t/mbox_reader.t
index 4ea2ae29..30a5e6e3 100644
--- a/t/mbox_reader.t
+++ b/t/mbox_reader.t
@@ -45,6 +45,8 @@ my $check_fmt = sub {
         seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!";
         $reader->$fmt($fh, sub {
                 my ($eml) = @_;
+                $eml->header_set('Status');
+                $eml->header_set('Lines');
                 my $cur = shift @order;
                 my @cl = $eml->header_raw('Content-Length');
                 if ($fmt =~ /\Amboxcl/) {