user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 8/8] lei rm: move generic input_maildir_cb to LeiInput parent class
Date: Thu, 28 Oct 2021 11:15:01 +0000	[thread overview]
Message-ID: <20211028111501.24014-9-e@80x24.org> (raw)
In-Reply-To: <20211028111501.24014-1-e@80x24.org>

It's not much of a savings, right now, but maybe it can be in the
future.  I wanted to eliminate the "lei convert" one, too, but
convert needs to preserve keywords which isn't possible with the
generic fallback, so new tests were written for convert, instead.
---
 lib/PublicInbox/LeiInput.pm |  5 +++++
 lib/PublicInbox/LeiRm.pm    |  5 -----
 t/lei-convert.t             | 10 ++++++++++
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm
index 540681e3ff6b..84fc579dc480 100644
--- a/lib/PublicInbox/LeiInput.pm
+++ b/lib/PublicInbox/LeiInput.pm
@@ -64,6 +64,11 @@ sub input_mbox_cb { # base MboxReader callback
 	$self->input_eml_cb($eml);
 }
 
+sub input_maildir_cb {
+	my ($fn, $kw, $eml, $self) = @_;
+	$self->input_eml_cb($eml);
+}
+
 sub input_net_cb { # imap_each, nntp_each cb
 	my ($url, $uid, $kw, $eml, $self) = @_;
 	$self->input_eml_cb($eml);
diff --git a/lib/PublicInbox/LeiRm.pm b/lib/PublicInbox/LeiRm.pm
index 524c178e3b47..cc1abbff66cb 100644
--- a/lib/PublicInbox/LeiRm.pm
+++ b/lib/PublicInbox/LeiRm.pm
@@ -13,11 +13,6 @@ sub input_eml_cb { # used by PublicInbox::LeiInput::input_fh
 	$self->{lei}->{sto}->wq_do('remove_eml', $eml);
 }
 
-sub input_maildir_cb {
-	my (undef, $kw, $eml, $self) = @_; # $_[0] $filename ignored
-	input_eml_cb($self, $eml);
-}
-
 sub lei_rm {
 	my ($lei, @inputs) = @_;
 	$lei->_lei_store(1)->write_prepare($lei);
diff --git a/t/lei-convert.t b/t/lei-convert.t
index 0ea860c82189..e1849ff796cd 100644
--- a/t/lei-convert.t
+++ b/t/lei-convert.t
@@ -115,5 +115,15 @@ test_lei({ tmpdir => $tmpdir }, sub {
 	@bar = ();
 	PublicInbox::MboxReader->mboxrd($fh, sub { push @bar, shift });
 	is_deeply(\@bar, [ $qp_eml ], 'readed gzipped mboxrd');
+
+	# Status => Maildir flag => Status round trip
+	$lei_out =~ s/^Status: O/Status: RO/sm or xbail "`seen' Status";
+	$rdr = { 0 => \($in = $lei_out), %$lei_opt };
+	lei_ok([qw(convert -F mboxrd -o), "$d/md2"], undef, $rdr);
+	@md = glob("$d/md2/*/*");
+	is(scalar(@md), 1, 'one message');
+	like($md[0], qr/:2,S\z/, "`seen' flag set in Maildir");
+	lei_ok(qw(convert -o mboxrd:/dev/stdout), "$d/md2");
+	like($lei_out, qr/^Status: RO/sm, "`seen' flag preserved");
 });
 done_testing;

      parent reply	other threads:[~2021-10-28 11:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 11:14 [PATCH 0/8] lei: docs and cleanups Eric Wong
2021-10-28 11:14 ` [PATCH 1/8] xt/net_writer_imap: test "lei convert" w/ IMAP source Eric Wong
2021-10-28 11:14 ` [PATCH 2/8] lei convert: use "--output" in failure message Eric Wong
2021-10-28 11:14 ` [PATCH 3/8] doc: lei-convert: various updates and cleanups Eric Wong
2021-10-28 11:14 ` [PATCH 4/8] doc: lei blob: wording fixups, describe --remote Eric Wong
2021-10-28 11:14 ` [PATCH 5/8] lei convert: remove redundant input_net_cb Eric Wong
2021-10-28 11:14 ` [PATCH 6/8] doc: lei-add-watch: add warning about unreliability Eric Wong
2021-10-28 11:15 ` [PATCH 7/8] lei sucks: show nproc in CPU info Eric Wong
2021-10-28 11:15 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211028111501.24014-9-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).