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:[email protected]));
+       $res = json_utf8->decode($lei_out);
+       is_deeply($res, [ undef ], 'trashed message not imported');
 });
 done_testing;
--
unsubscribe: one-click, see List-Unsubscribe header
archive: https://public-inbox.org/meta/

Reply via email to