unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/2] minor lei usability tweaks
@ 2021-08-25  8:40 Eric Wong
  2021-08-25  8:40 ` [PATCH 1/2] lei up: improve --all=local stderr output Eric Wong
  2021-08-25  8:40 ` [PATCH 2/2] lei_mail_sync: remove warning message from caller Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-25  8:40 UTC (permalink / raw)
  To: meta

Some things I noticed replacing much of my existing mail
stack with lei...

Eric Wong (2):
  lei up: improve --all=local stderr output
  lei_mail_sync: remove warning message from caller

 MANIFEST                       |  1 +
 lib/PublicInbox/LEI.pm         |  6 ++++++
 lib/PublicInbox/LeiFinmsg.pm   | 21 +++++++++++++++++++++
 lib/PublicInbox/LeiMailSync.pm |  2 +-
 lib/PublicInbox/LeiUp.pm       |  2 ++
 lib/PublicInbox/LeiXSearch.pm  |  9 ++++++---
 6 files changed, 37 insertions(+), 4 deletions(-)
 create mode 100644 lib/PublicInbox/LeiFinmsg.pm

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

* [PATCH 1/2] lei up: improve --all=local stderr output
  2021-08-25  8:40 [PATCH 0/2] minor lei usability tweaks Eric Wong
@ 2021-08-25  8:40 ` Eric Wong
  2021-08-25  8:40 ` [PATCH 2/2] lei_mail_sync: remove warning message from caller Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-25  8:40 UTC (permalink / raw)
  To: meta

The "# $NR written to $DEST ($total matches)" messages are
arguably the most useful output of "lei up --all=local",
but they get intermixed with progress messages from various
workers.  Queue up these finalization messages and only spit
them out on ->DESTROY.
---
 MANIFEST                      |  1 +
 lib/PublicInbox/LEI.pm        |  6 ++++++
 lib/PublicInbox/LeiFinmsg.pm  | 21 +++++++++++++++++++++
 lib/PublicInbox/LeiUp.pm      |  2 ++
 lib/PublicInbox/LeiXSearch.pm |  9 ++++++---
 5 files changed, 36 insertions(+), 3 deletions(-)
 create mode 100644 lib/PublicInbox/LeiFinmsg.pm

diff --git a/MANIFEST b/MANIFEST
index fb9f16bf..cf7268ed 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 5694e92c..28fe0c83 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -486,6 +486,12 @@ sub err ($;@) {
 
 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 00000000..0ef5f070
--- /dev/null
+++ b/lib/PublicInbox/LeiFinmsg.pm
@@ -0,0 +1,21 @@
+# Copyright (C) all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+
+# 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 ba11761a..85efd9f5 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -48,6 +48,8 @@ sub up1 ($$) {
 
 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 1f83e582..b9f0d692 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -398,9 +398,12 @@ Error closing $lei->{ovv}->{dst}: $!
 	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;

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

* [PATCH 2/2] lei_mail_sync: remove warning message from caller
  2021-08-25  8:40 [PATCH 0/2] minor lei usability tweaks Eric Wong
  2021-08-25  8:40 ` [PATCH 1/2] lei up: improve --all=local stderr output Eric Wong
@ 2021-08-25  8:40 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-25  8:40 UTC (permalink / raw)
  To: meta

We can afford to be liberal in what messages we accept
internally, since LeiToMail uses a trailing slash internally.
---
 lib/PublicInbox/LeiMailSync.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm
index 80e1bb9d..b63f8dea 100644
--- a/lib/PublicInbox/LeiMailSync.pm
+++ b/lib/PublicInbox/LeiMailSync.pm
@@ -79,8 +79,8 @@ sub fid_for {
 	my ($fid) = $dbh->selectrow_array($sel, undef, $folder);
 	return $fid if defined $fid;
 
+	# caller had trailing slash (LeiToMail)
 	if ($folder =~ s!\A((?:maildir|mh):.*?)/+\z!$1!i) {
-		warn "folder: $folder/ had trailing slash in arg\n";
 		($fid) = $dbh->selectrow_array($sel, undef, $folder);
 		if (defined $fid) {
 			$dbh->do(<<EOM, undef, $folder, $fid) if $rw;

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

end of thread, other threads:[~2021-08-25  8:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25  8:40 [PATCH 0/2] minor lei usability tweaks Eric Wong
2021-08-25  8:40 ` [PATCH 1/2] lei up: improve --all=local stderr output Eric Wong
2021-08-25  8:40 ` [PATCH 2/2] lei_mail_sync: remove warning message from caller Eric Wong

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 NNTP newsgroup(s).