X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWatchMaildir.pm;h=c15e138436cd8964e061a40f725212ef425103af;hb=403177efccc2b1c3883eb7b7dd3985d947828481;hp=d08f2297af159b9d3b18aa1ab1152bc3d671b965;hpb=3fc59df0d633a17e0c5e43d633d12e8772c06ec3;p=public-inbox.git diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index d08f2297..c15e1384 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -97,7 +97,8 @@ sub _try_fsn_paths { sub _remove_spam { my ($self, $path) = @_; - $path =~ /:2,[A-R]*S[T-Z]*\z/i or return; + # path must be marked as (S)een + $path =~ /:2,[A-R]*S[T-Za-z]*\z/ or return; my $mime = _path_to_mime($path) or return; _force_mid($mime); $self->{config}->each_inbox(sub { @@ -107,10 +108,14 @@ sub _remove_spam { $im->remove($mime); if (my $scrub = _scrubber_for($ibx)) { my $scrubbed = $scrub->scrub($mime) or return; + $scrubbed == 100 and return; $im->remove($scrubbed); } }; - warn "error removing spam at $path from $ibx->{name}\n" if $@; + if ($@) { + warn "error removing spam at: ", $path, + " from ", $ibx->{name}, ': ', $@, "\n"; + } }) } @@ -165,7 +170,9 @@ sub _try_path { return unless ($v && $v =~ $wm->[1]); } if (my $scrub = _scrubber_for($inbox)) { - $mime = $scrub->scrub($mime) or return; + my $ret = $scrub->scrub($mime) or return; + $ret == 100 and return; + $mime = $ret; } _force_mid($mime); @@ -224,18 +231,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 = (-inbox => $inbox); + # 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;