From f9f1d228bd60c1aa3d16786f9ccee21635731d45 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 25 Nov 2011 18:25:11 -0500 Subject: [PATCH] I fixed this script in a few ways a few weeks ago, but forgot to commit. --- remove-spam-high-confidence-maildir.plx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/remove-spam-high-confidence-maildir.plx b/remove-spam-high-confidence-maildir.plx index a110a89..d288ec1 100755 --- a/remove-spam-high-confidence-maildir.plx +++ b/remove-spam-high-confidence-maildir.plx @@ -25,6 +25,7 @@ use Date::Manip; #use File::Copy; +my $VERBOSE = 1; if (@ARGV < 4 or @ARGV > 5) { print STDERR "usage: $0 []\n"; @@ -43,9 +44,9 @@ foreach my $dir (@msgDirs) { die "$MAILDIR_FOLDER must not be a maildir folder (or is unreadable by you), since $dir isn't a readable directory: $!" unless (-d $dir); } -MAIL: foreach my $dir (@msgDirs) { +foreach my $dir (@msgDirs) { opendir(MAILDIR, $dir) or die "Unable to open directory $dir for reading: $!"; - while (my $file = readdir MAILDIR) { +MAIL: while (my $file = readdir MAILDIR) { next if -d $file; # skip directories my $fullFileName = "$dir/$file"; @@ -75,11 +76,15 @@ MAIL: foreach my $dir (@msgDirs) { next MAIL; } + print "\nDate: $parsedDate" if ($VERBOSE > 2); + next MAIL if ($parsedDate gt $nDaysAgo); + print " Not skipping over date, $nDaysAgo\n" if ($VERBOSE > 2); my %dspamVal; foreach my $val ('Confidence', 'Probability') { foreach my $dv (@{$fields->{"X-Dspam-$val"}}) { + chomp $dv; if (not defined $dspamVal{$val}) { $dspamVal{$val} = $dv; } else { @@ -93,9 +98,13 @@ MAIL: foreach my $dir (@msgDirs) { } $total++; + print " Confidence: $dspamVal{Confidence}, Probability: $dspamVal{Probability}\n" + if ($VERBOSE > 2); + if ($dspamVal{Confidence} >= $DSPAM_CONF_MIN and $dspamVal{Probability} >= $DSPAM_PROB_MIN) { $countDeleted++; + print " counting this one\n" if ($VERBOSE > 2); unless (defined $COUNT_ONLY and $COUNT_ONLY) { warn "unable to unlink $fullFileName: $!" unless unlink("$fullFileName") == 1;