diff options
author | Eric Wong <e@80x24.org> | 2017-02-09 00:43:02 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-02-09 00:43:02 +0000 |
commit | fb9ed5324ec7de9420956840ba9a6585b81e8231 (patch) | |
tree | ab6b34f8459a585205a25d1f3d18d31437b89052 /lib/PublicInbox/WatchMaildir.pm | |
parent | 1ab8dabe04ebba61fd8761dca3d569947cbe20be (diff) | |
parent | ba4c50c20b95679580beba1ef290a4281d5285b7 (diff) | |
download | public-inbox-fb9ed5324ec7de9420956840ba9a6585b81e8231.tar.gz |
* origin/master: config: do not slurp lines into memory TODO: several updates search: schema version bump for empty References/In-Reply-To Revert "searchidx: reindex clobbers old thread IDs" searchidx: reindex clobbers old thread IDs searchidx: deal with empty In-Reply-To and References headers searchview: increase limit for displaying search results searchview: clarify numeric summary at bottom add filter for Subject: tags watchmaildir: allow arguments for filters watchmaildir: limit live importer processes learn: implement "rm" only functionality mime: avoid SUPER usage in Email::MIME subclass inbox: reinstate periodic cleanup of Xapian and SQLite objects introduce PublicInbox::MIME wrapper class
Diffstat (limited to 'lib/PublicInbox/WatchMaildir.pm')
-rw-r--r-- | lib/PublicInbox/WatchMaildir.pm | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index b7c2d17a..1823c248 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -6,7 +6,7 @@ package PublicInbox::WatchMaildir; use strict; use warnings; -use Email::MIME; +use PublicInbox::MIME; use Email::MIME::ContentType; $Email::MIME::ContentType::STRICT_PARAMS = 0; # user input is imperfect use PublicInbox::Git; @@ -207,7 +207,7 @@ sub _path_to_mime { local $/; my $str = <$fh>; $str or return; - return Email::MIME->new(\$str); + return PublicInbox::MIME->new(\$str); } elsif ($!{ENOENT}) { return; } else { @@ -224,18 +224,31 @@ sub _importer_for { my $addr = $inbox->{-primary_address}; PublicInbox::Import->new($git, $name, $addr, $inbox); }; - $self->{importers}->{"$im"} = $im; + + my $importers = $self->{importers}; + if (scalar(keys(%$importers)) > 2) { + delete $importers->{"$im"}; + _done_for_now($self); + } + + $importers->{"$im"} = $im; } sub _scrubber_for { my ($inbox) = @_; my $f = $inbox->{filter}; if ($f && $f =~ /::/) { + my @args; + # basic line splitting, only + # Perhaps we can have proper quote splitting one day... + ($f, @args) = split(/\s+/, $f) if $f =~ /\s+/; + eval "require $f"; if ($@) { warn $@; } else { - return $f->new; + # e.g: PublicInbox::Filter::Vger->new(@args) + return $f->new(@args); } } undef; @@ -247,7 +260,7 @@ sub _spamcheck_cb { my ($mime) = @_; my $tmp = ''; if ($sc->spamcheck($mime, \$tmp)) { - return Email::MIME->new(\$tmp); + return PublicInbox::MIME->new(\$tmp); } warn $mime->header('Message-ID')." failed spam check\n"; undef; |