From 3fc59df0d633a17e0c5e43d633d12e8772c06ec3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 10 Jan 2017 21:40:37 +0000 Subject: introduce PublicInbox::MIME wrapper class This should fix problems with multipart messages where text/plain parts lack a header. cf. git clone --mirror https://github.com/rjbs/Email-MIME.git refs/pull/28/head In the future, we may still introduce as streaming interface to reduce memory usage on large emails. --- lib/PublicInbox/WatchMaildir.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/WatchMaildir.pm') diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index b7c2d17a..d08f2297 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 { @@ -247,7 +247,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; -- cgit v1.2.3-24-ge0c7 From c265481528208a832c5731b8da597554f2a8f693 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 18 Jan 2017 19:13:09 +0000 Subject: watchmaildir: limit live importer processes We don't want to be triggering OOM or swapping on weaker systems when we have dozens of inboxes as potential targets. --- lib/PublicInbox/WatchMaildir.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/WatchMaildir.pm') diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index d08f2297..0b284bdb 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -224,7 +224,14 @@ 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 { -- cgit v1.2.3-24-ge0c7 From a465cc132b8d1ad96dbd0f51ad6da2ce75c79568 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 25 Jan 2017 21:39:06 +0000 Subject: watchmaildir: allow arguments for filters We'll want to allow some degree of configuration for various mailing lists. --- lib/PublicInbox/WatchMaildir.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/WatchMaildir.pm') diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index 0b284bdb..1823c248 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -238,11 +238,17 @@ 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; -- cgit v1.2.3-24-ge0c7