about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/WatchMaildir.pm12
-rw-r--r--t/watch_maildir.t3
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index cb64f899..4468a448 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -71,6 +71,7 @@ sub _try_fsn_paths {
 
 sub _check_spam {
         my ($self, $path) = @_;
+        $path =~ /:2,[A-R]*S[T-Z]*\z/ or return;
         my $mime = _path_to_mime($path) or return;
         _force_mid($mime);
         foreach my $inbox (values %{$self->{mdmap}}) {
@@ -107,6 +108,9 @@ 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 unless -f $path;
         if ($path !~ $self->{mdre}) {
                 warn "unrecognized path: $path\n";
                 return;
@@ -155,13 +159,7 @@ sub scan {
                         next;
                 }
                 while (my $fn = readdir($dh)) {
-                        next unless $fn =~ /\A[a-zA-Z0-9][\w:,=\.]+\z/;
-                        $fn = "$dir/$fn";
-                        if (-f $fn) {
-                                _try_path($self, $fn);
-                        } else {
-                                warn "not a file: $fn\n";
-                        }
+                        _try_path($self, "$dir/$fn");
                 }
                 closedir $dh;
         }
diff --git a/t/watch_maildir.t b/t/watch_maildir.t
index 8a2c934a..e8c97406 100644
--- a/t/watch_maildir.t
+++ b/t/watch_maildir.t
@@ -25,6 +25,7 @@ Date: Sat, 18 Jun 2016 00:00:00 +0000
 something
 EOF
 PublicInbox::Emergency->new($maildir)->prepare(\$msg);
+ok(POSIX::mkfifo("$maildir/cur/fifo", 0777));
 my $sem = PublicInbox::Emergency->new($spamdir); # create dirs
 
 my $config = PublicInbox::Config->new({
@@ -47,7 +48,7 @@ my $write_spam = sub {
         my @new = glob("$spamdir/new/*");
         is(scalar @new, 1);
         my @p = split(m!/+!, $new[0]);
-        ok(link($new[0], "$spamdir/cur/".$p[-1]));
+        ok(link($new[0], "$spamdir/cur/".$p[-1].":2,S"));
         is(unlink($new[0]), 1);
 };
 $write_spam->();