From 7a7034a3264ac99523e661c41fc9ba320a4b3766 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 9 Jun 2021 07:47:47 +0000 Subject: inbox_writable: fix import_maildir 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(-) (limited to 'lib') 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; } -- cgit v1.2.3-24-ge0c7