user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] lei q: fix remote import accounting
@ 2021-10-27 21:09 Eric Wong
  2021-10-27 21:28 ` Thomas Weißschuh
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2021-10-27 21:09 UTC (permalink / raw)
  To: meta; +Cc: Thomas Weißschuh

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>
---
 lib/PublicInbox/LeiXSearch.pm | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index acc36897d4e3..2a037f2bd79b 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;
 		}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] lei q: fix remote import accounting
  2021-10-27 21:09 [PATCH] lei q: fix remote import accounting Eric Wong
@ 2021-10-27 21:28 ` Thomas Weißschuh
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Weißschuh @ 2021-10-27 21:28 UTC (permalink / raw)
  To: Eric Wong; +Cc: meta

On 2021-10-27 21:09+0000, Eric Wong wrote:
> 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>

For the record: This patch did in fact *not* fix the issue.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-27 21:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 21:09 [PATCH] lei q: fix remote import accounting Eric Wong
2021-10-27 21:28 ` Thomas Weißschuh

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

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).