about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiToMail.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-07-07 09:40:30 +0000
committerEric Wong <e@80x24.org>2022-07-07 09:47:58 +0000
commit6313d8bbc5f3816eb4936443fca57b411f4f6286 (patch)
tree02a5f01b8c85d610b78807aa8cbfc4a13d556cdf /lib/PublicInbox/LeiToMail.pm
parente85ea061aa504e490bccbaad8d249ce039c0ab53 (diff)
downloadpublic-inbox-6313d8bbc5f3816eb4936443fca57b411f4f6286.tar.gz
This may help track down deduplication or other bugs in lei
which lead to occasionally missing messages.

Link: https://public-inbox.org/meta/CAL_JsqJH8xx_2NyZffNsRXbGXiv3kjmCETvKXt3Yfb0uToLm9Q@mail.gmail.com/
Diffstat (limited to 'lib/PublicInbox/LeiToMail.pm')
-rw-r--r--lib/PublicInbox/LeiToMail.pm13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm
index 3c5e7e59..2aa3977e 100644
--- a/lib/PublicInbox/LeiToMail.pm
+++ b/lib/PublicInbox/LeiToMail.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Writes PublicInbox::Eml objects atomically to a mbox variant or Maildir
@@ -197,6 +197,7 @@ sub _mbox_write_cb ($$) {
         sub { # for git_to_mail
                 my ($buf, $smsg, $eml) = @_;
                 $eml //= PublicInbox::Eml->new($buf);
+                ++$lei->{-nr_seen};
                 return if $dedupe->is_dup($eml, $smsg);
                 $lse->xsmsg_vmd($smsg) if $lse;
                 $smsg->{-recent} = 1 if $set_recent;
@@ -291,6 +292,8 @@ sub _maildir_write_cb ($$) {
         sub { # for git_to_mail
                 my ($bref, $smsg, $eml) = @_;
                 $dst // return $lei->fail; # dst may be undef-ed in last run
+
+                ++$lei->{-nr_seen};
                 return if $dedupe && $dedupe->is_dup($eml //
                                                 PublicInbox::Eml->new($$bref),
                                                 $smsg);
@@ -317,6 +320,8 @@ sub _imap_write_cb ($$) {
         sub { # for git_to_mail
                 my ($bref, $smsg, $eml) = @_;
                 $mic // return $lei->fail; # mic may be undef-ed in last run
+
+                ++$lei->{-nr_seen};
                 return if $dedupe && $dedupe->is_dup($eml //
                                                 PublicInbox::Eml->new($$bref),
                                                 $smsg);
@@ -360,6 +365,7 @@ sub _v2_write_cb ($$) {
         sub { # for git_to_mail
                 my ($bref, $smsg, $eml) = @_;
                 $eml //= PublicInbox::Eml->new($bref);
+                ++$lei->{-nr_seen};
                 return if $dedupe && $dedupe->is_dup($eml, $smsg);
                 $lei->{v2w}->wq_do('add', $eml); # V2Writable->add
                 ++$lei->{-nr_write};
@@ -792,9 +798,10 @@ sub wq_atexit_child {
         my $lei = $self->{lei};
         delete $self->{wcb};
         $lei->{ale}->git->async_wait_all;
-        my $nr = delete($lei->{-nr_write}) or return;
+        my ($nr_w, $nr_s) = delete(@$lei{qw(-nr_write -nr_seen)});
+        $nr_s or return;
         return if $lei->{early_mua} || !$lei->{-progress} || !$lei->{pkt_op_p};
-        $lei->{pkt_op_p}->pkt_do('l2m_progress', $nr);
+        $lei->{pkt_op_p}->pkt_do('l2m_progress', $nr_w, $nr_s);
 }
 
 # runs on a 1s timer in lei-daemon