From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.8 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EE6BE20193 for ; Fri, 24 Jun 2016 20:47:18 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/6] watch_maildir: ignore Trash and Drafts, support Dovecot Date: Fri, 24 Jun 2016 20:47:18 +0000 Message-Id: <20160624204718.27540-6-e@80x24.org> In-Reply-To: <20160624204718.27540-1-e@80x24.org> References: <20160624204718.27540-1-e@80x24.org> List-Id: Trashed messages and drafts are probably not intended for importing, so do not import them. Dovecot uses extra flags via lowercase letters, so we must support those (as that's the server I use). --- lib/PublicInbox/WatchMaildir.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index 72bd3d0..b25704e 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -1,5 +1,8 @@ # Copyright (C) 2016 all contributors # License: AGPL-3.0+ +# +# ref: https://cr.yp.to/proto/maildir.html +# http://wiki2.dovecot.org/MailboxFormat/Maildir package PublicInbox::WatchMaildir; use strict; use warnings; @@ -89,7 +92,7 @@ sub _try_fsn_paths { sub _remove_spam { my ($self, $path) = @_; - $path =~ /:2,[A-R]*S[T-Z]*\z/ or return; + $path =~ /:2,[A-R]*S[T-Z]*\z/i or return; my $mime = _path_to_mime($path) or return; _force_mid($mime); foreach my $inbox (values %{$self->{mdmap}}) { @@ -127,7 +130,11 @@ sub _force_mid { sub _try_path { my ($self, $path) = @_; my @p = split(m!/+!, $path); - return unless $p[-1] =~ /\A[a-zA-Z0-9][\w:,=\.]+\z/; + return if $p[-1] !~ /\A[a-zA-Z0-9][\w:,=\.]+\z/; + if ($p[-1] =~ /:2,([A-Z]+)\z/i) { + my $flags = $1; + return if $flags =~ /[DT]/; # no [D]rafts or [T]rashed mail + } return unless -f $path; if ($path !~ $self->{mdre}) { warn "unrecognized path: $path\n";