From: Eric Wong Date: Wed, 10 Mar 2021 13:23:44 +0000 (+0000) Subject: lei import: skip trashed Maildir messages X-Git-Tag: v1.7.0~1025 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=2399a0133868e8fffbe86e0ebff8b862d52e7e1e;p=public-inbox.git lei import: skip trashed Maildir messages 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". --- 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;