MANIFEST | 1 +
lib/PublicInbox/LEI.pm | 6 ++++++
lib/PublicInbox/LeiFinmsg.pm | 21 +++++++++++++++++++++
lib/PublicInbox/LeiUp.pm | 2 ++
lib/PublicInbox/LeiXSearch.pm | 9 ++++++---
diff --git a/MANIFEST b/MANIFEST
index fb9f16bfb37ebb3d8f20a80570aa77754ceed306..cf7268ed19a9783b858b2b6bda47a344950ba77c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -208,6 +208,7 @@ lib/PublicInbox/LeiDedupe.pm
lib/PublicInbox/LeiEditSearch.pm
lib/PublicInbox/LeiExportKw.pm
lib/PublicInbox/LeiExternal.pm
+lib/PublicInbox/LeiFinmsg.pm
lib/PublicInbox/LeiForgetMailSync.pm
lib/PublicInbox/LeiForgetSearch.pm
lib/PublicInbox/LeiHelp.pm
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 5694e92c92001d755cc3062b7d446edce067cf37..28fe0c836d7a3e842217b9bfd3cf63ac8ece2bf8 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -486,6 +486,12 @@ }
sub qerr ($;@) { $_[0]->{opt}->{quiet} or err(shift, @_) }
+sub qfin { # show message on finalization (LeiFinmsg)
+ my ($lei, $msg) = @_;
+ return if $lei->{opt}->{quiet};
+ $lei->{fmsg} ? push(@{$lei->{fmsg}}, "$msg\n") : qerr($lei, $msg);
+}
+
sub fail_handler ($;$$) {
my ($lei, $code, $io) = @_;
close($io) if $io; # needed to avoid warnings on SIGPIPE
diff --git a/lib/PublicInbox/LeiFinmsg.pm b/lib/PublicInbox/LeiFinmsg.pm
new file mode 100644
index 0000000000000000000000000000000000000000..0ef5f070201f226bf59dfece4c6564ee223b64f8
--- /dev/null
+++ b/lib/PublicInbox/LeiFinmsg.pm
@@ -0,0 +1,21 @@
+# Copyright (C) all contributors
+# License: AGPL-3.0+
+
+# Finalization messages, used to queue up a bunch of messages which
+# only get written out on ->DESTROY
+package PublicInbox::LeiFinmsg;
+use strict;
+use v5.10.1;
+
+sub new {
+ my ($cls, $io) = @_;
+ bless [ $io ], $cls;
+}
+
+sub DESTROY {
+ my ($self) = @_;
+ my $io = shift @$self;
+ print $io @$self;
+}
+
+1;
diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm
index ba11761a69df86b15c16a33467efe675e327973e..85efd9f5ded69c69341332566d61d2a1f8f6466e 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -48,6 +48,8 @@ }
sub up1_redispatch {
my ($lei, $out, $op_p) = @_;
+ require PublicInbox::LeiFinmsg;
+ $lei->{fmsg} //= PublicInbox::LeiFinmsg->new($lei->{2});
my $l = bless { %$lei }, ref($lei);
$l->{opt} = { %{$l->{opt}} };
delete $l->{sock};
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 1f83e582055c7ef06d40ffae5b632efbd484778b..b9f0d6924d4ca5c9617435e3d5081cc9c65db16e 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -398,9 +398,12 @@ }
if ($lei->{-progress}) {
my $tot = $lei->{-mset_total} // 0;
my $nr = $lei->{-nr_write} // 0;
- $lei->qerr($l2m ?
- "# $nr written to $lei->{ovv}->{dst} ($tot matches)" :
- "# $tot matches");
+ if ($l2m) {
+ $lei->qfin("# $nr written to " .
+ "$lei->{ovv}->{dst} ($tot matches)");
+ } else {
+ $lei->qerr("# $tot matches");
+ }
}
$lei->start_mua if $start_mua;
$lei->dclose;