]> diplodocus.org Git - minc/commitdiff
Handle files in $maildir/spam (from new mdeliver processor).
authorepg <>
Thu, 30 Mar 2006 03:08:12 +0000 (03:08 +0000)
committerepg <>
Thu, 30 Mar 2006 03:08:12 +0000 (03:08 +0000)
minc

diff --git a/minc b/minc
index eba819f..fbeba15 100755 (executable)
--- a/minc
+++ b/minc
@@ -743,6 +743,34 @@ sub update_dot_folders {
     build_dot_folders($folders, $fh);
 }
 
+# XXX Could use some unification with getfiles...
+sub maildir_spam {
+    my $dir = "$MAILDIR/spam";
+
+    if (not chdir($dir)) {
+        print(STDERR "skipping maildir spam: chdir($dir): $!\n");
+        return;
+    }
+
+    if (not opendir(DIR, '.')) {
+        print(STDERR "skipping maildir spam: opendir($dir): $!\n");
+        return;
+    }
+
+    $! = 0;
+    my @spams = readdir(DIR);
+    if ($! != 0) {
+        print(STDERR "skipping maildir spam: readdir($dir): $!\n");
+    }
+
+    closedir(DIR);
+
+    for my $msg (@spams) {
+        ($msg eq '.' or $msg eq '..') and next;
+        store_message($msg, 'SPAM');
+    }
+}
+
 \f
 MAIN: {
     my $st;
@@ -769,6 +797,8 @@ MAIN: {
 
     $run and update_dot_folders(\%folders);
 
+    maildir_spam();
+
     @SPAM and (exec('scan', '+SPAM', @SPAM) or die);
 }