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 1/5] inbox_writable: fix import_maildir
Date: Wed,  9 Jun 2021 07:47:47 +0000	[thread overview]
Message-ID: <20210609074751.29217-2-e@80x24.org> (raw)
In-Reply-To: <20210609074751.29217-1-e@80x24.org>

I'm not sure if anybody uses this, but it exists.  It'll likely
be dropped in the future.

Fixes: fa3f0cbcd1af5008 ("use MdirReader in -watch and InboxWritable")
---
 lib/PublicInbox/InboxWritable.pm | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index 45d8cdc7..65539781 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -131,13 +131,9 @@ sub eml_from_path ($) {
 	}
 }
 
-sub _each_maildir_fn {
-	my ($fn, $im, $self) = @_;
-	if ($fn =~ /:2,([A-Za-z]*)\z/) {
-		my $fl = $1;
-		return if $fl =~ /[DT]/; # no Drafts or Trash for public
-	}
-	my $eml = eml_from_path($fn) or return;
+sub _each_maildir_eml {
+	my ($fn, $kw, $eml, $im, $self) = @_;
+	return if grep(/\Adraft\z/, @$kw);
 	if ($self && (my $filter = $self->filter($im))) {
 		my $ret = $filter->scrub($eml) or return;
 		return if $ret == REJECT();
@@ -146,6 +142,7 @@ sub _each_maildir_fn {
 	$im->add($eml);
 }
 
+# XXX does anybody use this?
 sub import_maildir {
 	my ($self, $dir) = @_;
 	foreach my $sub (qw(cur new tmp)) {
@@ -154,8 +151,8 @@ sub import_maildir {
 	my $im = $self->importer(1);
 	my @self = $self->filter($im) ? ($self) : ();
 	require PublicInbox::MdirReader;
-	PublicInbox::MdirReader->new->maildir_each_file(\&_each_maildir_fn,
-							$im, @self);
+	PublicInbox::MdirReader->new->maildir_each_eml($dir,
+					\&_each_maildir_eml, $im, @self);
 	$im->done;
 }
 

  reply	other threads:[~2021-06-09  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09  7:47 [PATCH 0/5] lei Maildir stuff Eric Wong
2021-06-09  7:47 ` Eric Wong [this message]
2021-06-09  7:47 ` [PATCH 2/5] mdir_reader: maildir_each_file: pass flags, skip Trash Eric Wong
2021-06-09  7:47 ` [PATCH 3/5] lei tag: parallelize Maildir access Eric Wong
2021-06-09  7:47 ` [PATCH 4/5] lei_mail_sync: hoist out --all handling from export-kw Eric Wong
2021-06-09  7:47 ` [PATCH 5/5] lei prune-mail-sync: new command to prune invalid sync data Eric Wong

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=20210609074751.29217-2-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).