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-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 E386D1FB0E for ; Wed, 10 Mar 2021 13:23:45 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/5] lei import: skip trashed Maildir messages Date: Wed, 10 Mar 2021 13:23:44 +0000 Message-Id: <20210310132345.28283-5-e@80x24.org> In-Reply-To: <20210310132345.28283-1-e@80x24.org> References: <20210310132345.28283-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This matches IMAP behavior in NetReader in skipping \\Deleted messages. Since lei may be used for personal, non-public mail; Draft messages are NOT skipped by "lei import". --- lib/PublicInbox/MdirReader.pm | 1 + t/lei-import-maildir.t | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/PublicInbox/MdirReader.pm b/lib/PublicInbox/MdirReader.pm index 44724af1..06806e80 100644 --- a/lib/PublicInbox/MdirReader.pm +++ b/lib/PublicInbox/MdirReader.pm @@ -57,6 +57,7 @@ sub maildir_each_eml ($$;@) { opendir my $dh, $pfx or return; while (defined(my $bn = readdir($dh))) { my $fl = maildir_basename_flags($bn) // next; + next if index($fl, 'T') >= 0; my $f = $pfx.$bn; my $eml = eml_from_path($f) or next; my @kw = sort(map { $c2kw{$_} // () } split(//, $fl)); diff --git a/t/lei-import-maildir.t b/t/lei-import-maildir.t index a3796491..bd89677a 100644 --- a/t/lei-import-maildir.t +++ b/t/lei-import-maildir.t @@ -29,5 +29,12 @@ test_lei(sub { like($res->[0]->{'s'}, qr/use boolean/, 'got expected result'); is_deeply($res->[0]->{kw}, ['answered', 'seen'], 'keywords set'); is($res->[1], undef, 'only got one result'); + + symlink(abs_path('t/utf8.eml'), "$md/cur/u:2,ST") or + BAIL_OUT "symlink $md $!"; + lei_ok('import', "maildir:$md", \'import Maildir w/ trashed message'); + lei_ok(qw(q -d none m:testmessage@example.com)); + $res = json_utf8->decode($lei_out); + is_deeply($res, [ undef ], 'trashed message not imported'); }); done_testing;