X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWatchMaildir.pm;h=7b9e891508aa069ce2981ffd4baa45ff102dc025;hb=b3a04ae18a42ed960c89cc81c209633da6976380;hp=003baec90f3d14905a09d210744fdaedd60468c2;hpb=48d4fdb2acbf8cf05dcb357df53b0d658f88fe39;p=public-inbox.git
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 003baec9..7b9e8915 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2019 all contributors
+# Copyright (C) 2016-2020 all contributors
# License: AGPL-3.0+
#
# ref: https://cr.yp.to/proto/maildir.html
@@ -7,13 +7,11 @@ package PublicInbox::WatchMaildir;
use strict;
use warnings;
use PublicInbox::MIME;
-use PublicInbox::Spawn qw(spawn);
use PublicInbox::InboxWritable;
-use File::Temp 0.19 ();
-use PublicInbox::Filter::Base;
+use File::Temp 0.19 (); # 0.19 for ->newdir
+use PublicInbox::Filter::Base qw(REJECT);
use PublicInbox::Spamcheck;
-*REJECT = *PublicInbox::Filter::Base::REJECT;
-*maildir_path_load = *PublicInbox::InboxWritable::maildir_path_load;
+*mime_from_path = \&PublicInbox::InboxWritable::mime_from_path;
sub new {
my ($class, $config) = @_;
@@ -61,9 +59,11 @@ sub new {
my $watch = $ibx->{watch} or return;
if (is_maildir($watch)) {
my $watch_hdrs = [];
- if (my $wh = $ibx->{watchheader}) {
- my ($k, $v) = split(/:/, $wh, 2);
- push @$watch_hdrs, [ $k, qr/\Q$v\E/ ];
+ if (my $whs = $ibx->{watchheader}) {
+ for (@$whs) {
+ my ($k, $v) = split(/:/, $_, 2);
+ push @$watch_hdrs, [ $k, qr/\Q$v\E/ ];
+ }
}
if (my $list_ids = $ibx->{listid}) {
for (@$list_ids) {
@@ -125,7 +125,7 @@ sub _remove_spam {
my ($self, $path) = @_;
# path must be marked as (S)een
$path =~ /:2,[A-R]*S[T-Za-z]*\z/ or return;
- my $mime = maildir_path_load($path) or return;
+ my $mime = mime_from_path($path) or return;
$self->{config}->each_inbox(sub {
my ($ibx) = @_;
eval {
@@ -167,7 +167,7 @@ sub _try_path {
$warn_cb->(@_);
};
foreach my $ibx (@$inboxes) {
- my $mime = maildir_path_load($path) or next;
+ my $mime = mime_from_path($path) or next;
my $im = _importer_for($self, $ibx);
# any header match means it's eligible for the inbox:
@@ -204,7 +204,8 @@ sub watch {
# lazy load here, we may support watching via IMAP IDLE
# in the future...
- require Filesys::Notify::Simple;
+ eval { require Filesys::Notify::Simple } or
+ die "Filesys::Notify::Simple is currently required for $0\n";
my $fsn = Filesys::Notify::Simple->new([@{$self->{mdir}}, $scandir]);
$fsn->wait($cb) until $self->{quit};
}