about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-27 21:09:19 +0000
committerEric Wong <e@80x24.org>2021-10-27 23:23:41 +0000
commitac8eed6ecb389821eaafda7c695a2b99023dde4f (patch)
treed82c0d133da9636762518b606a108a690c6e227e /lib
parentded9dad254c15aded6f8a1cf6b11e51e325b872d (diff)
downloadpublic-inbox-ac8eed6ecb389821eaafda7c695a2b99023dde4f.tar.gz
We need to update the {-nr_remote_eml} counter regardless
of progress display being enabled since it's needed for
saved searches.  We'll also split out the {-imported} flag
separately and only call LeiStore->done if a new message
was imported.

Note: this change is NOT expected to fix errors reported by
Thomas in <ebf92218-1470-4602-b534-6dae59639dc6@t-8ch.de>

Cc: Thomas Weißschuh <thomas@t-8ch.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/LeiXSearch.pm17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index acc36897..2a037f2b 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -283,20 +283,22 @@ sub each_remote_eml { # callback for MboxReader->mboxrd
         my $smsg = bless {}, 'PublicInbox::Smsg';
         if ($self->{import_sto} && !$xoids) {
                 my ($res, $kw) = $self->{import_sto}->wq_do('add_eml', $eml);
-                $smsg = $res if ref($res) eq ref($smsg); # totally new message
+                if (ref($res) eq ref($smsg)) { # totally new message
+                        $smsg = $res;
+                        $self->{-imported} = 1;
+                }
                 $smsg->{kw} = $kw; # short-circuit xsmsg_vmd
         }
         $smsg->{blob} //= $xoids ? (keys(%$xoids))[0]
                                 : $lei->git_oid($eml)->hexdigest;
         _smsg_fill($smsg, $eml);
         wait_startq($lei);
+        my $nr = ++$lei->{-nr_remote_eml}; # needed for lss->cfg_set
         if ($lei->{-progress}) {
-                ++$lei->{-nr_remote_eml};
                 my $now = now();
                 my $next = $lei->{-next_progress} //= ($now + 1);
                 if ($now > $next) {
                         $lei->{-next_progress} = $now + 1;
-                        my $nr = $lei->{-nr_remote_eml};
                         mset_progress($lei, $lei->{-current_url}, $nr, '?');
                 }
         }
@@ -374,13 +376,14 @@ sub query_remote_mboxrd {
                 $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1);
                 PublicInbox::MboxReader->mboxrd($fh, \&each_remote_eml, $self,
                                                 $lei, $each_smsg);
-                my $nr = $lei->{-nr_remote_eml};
-                my $wait = $lei->{sto}->wq_do('done') if $nr && $lei->{sto};
+                if ($self->{import_sto} && delete($self->{-imported})) {
+                        my $wait = $self->{import_sto}->wq_do('done');
+                }
                 $reap_curl->join;
                 if ($? == 0) {
                         # don't update if no results, maybe MTA is down
-                        $key && $nr and
-                                $lei->{lss}->cfg_set($key, $start);
+                        my $nr = $lei->{-nr_remote_eml};
+                        $lei->{lss}->cfg_set($key, $start) if $key && $nr;
                         mset_progress($lei, $lei->{-current_url}, $nr, $nr);
                         next;
                 }