From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 99AB51F9E5 for ; Wed, 9 Jun 2021 07:47:51 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/5] inbox_writable: fix import_maildir Date: Wed, 9 Jun 2021 07:47:47 +0000 Message-Id: <20210609074751.29217-2-e@80x24.org> In-Reply-To: <20210609074751.29217-1-e@80x24.org> References: <20210609074751.29217-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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; }