I fixed this script in a few ways a few weeks ago, but forgot to commit.
This commit is contained in:
parent
0c69e5fea2
commit
f9f1d228bd
1 changed files with 11 additions and 2 deletions
|
@ -25,6 +25,7 @@ use Date::Manip;
|
||||||
|
|
||||||
#use File::Copy;
|
#use File::Copy;
|
||||||
|
|
||||||
|
my $VERBOSE = 1;
|
||||||
|
|
||||||
if (@ARGV < 4 or @ARGV > 5) {
|
if (@ARGV < 4 or @ARGV > 5) {
|
||||||
print STDERR "usage: $0 <MAILDIR_DIRECTORY> <DSPAM_PROBABILITY_MIN> <DSPAM_CONFIDENCE_LEVEL_MIN> <DAYS> [<COUNT_ONLY_DONT_DELETE>]\n";
|
print STDERR "usage: $0 <MAILDIR_DIRECTORY> <DSPAM_PROBABILITY_MIN> <DSPAM_CONFIDENCE_LEVEL_MIN> <DAYS> [<COUNT_ONLY_DONT_DELETE>]\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: $!"
|
die "$MAILDIR_FOLDER must not be a maildir folder (or is unreadable by you), since $dir isn't a readable directory: $!"
|
||||||
unless (-d $dir);
|
unless (-d $dir);
|
||||||
}
|
}
|
||||||
MAIL: foreach my $dir (@msgDirs) {
|
foreach my $dir (@msgDirs) {
|
||||||
opendir(MAILDIR, $dir) or die "Unable to open directory $dir for reading: $!";
|
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
|
next if -d $file; # skip directories
|
||||||
my $fullFileName = "$dir/$file";
|
my $fullFileName = "$dir/$file";
|
||||||
|
|
||||||
|
@ -75,11 +76,15 @@ MAIL: foreach my $dir (@msgDirs) {
|
||||||
next MAIL;
|
next MAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print "\nDate: $parsedDate" if ($VERBOSE > 2);
|
||||||
|
|
||||||
next MAIL if ($parsedDate gt $nDaysAgo);
|
next MAIL if ($parsedDate gt $nDaysAgo);
|
||||||
|
|
||||||
|
print " Not skipping over date, $nDaysAgo\n" if ($VERBOSE > 2);
|
||||||
my %dspamVal;
|
my %dspamVal;
|
||||||
foreach my $val ('Confidence', 'Probability') {
|
foreach my $val ('Confidence', 'Probability') {
|
||||||
foreach my $dv (@{$fields->{"X-Dspam-$val"}}) {
|
foreach my $dv (@{$fields->{"X-Dspam-$val"}}) {
|
||||||
|
chomp $dv;
|
||||||
if (not defined $dspamVal{$val}) {
|
if (not defined $dspamVal{$val}) {
|
||||||
$dspamVal{$val} = $dv;
|
$dspamVal{$val} = $dv;
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,9 +98,13 @@ MAIL: foreach my $dir (@msgDirs) {
|
||||||
}
|
}
|
||||||
$total++;
|
$total++;
|
||||||
|
|
||||||
|
print " Confidence: $dspamVal{Confidence}, Probability: $dspamVal{Probability}\n"
|
||||||
|
if ($VERBOSE > 2);
|
||||||
|
|
||||||
if ($dspamVal{Confidence} >= $DSPAM_CONF_MIN and
|
if ($dspamVal{Confidence} >= $DSPAM_CONF_MIN and
|
||||||
$dspamVal{Probability} >= $DSPAM_PROB_MIN) {
|
$dspamVal{Probability} >= $DSPAM_PROB_MIN) {
|
||||||
$countDeleted++;
|
$countDeleted++;
|
||||||
|
print " counting this one\n" if ($VERBOSE > 2);
|
||||||
unless (defined $COUNT_ONLY and $COUNT_ONLY) {
|
unless (defined $COUNT_ONLY and $COUNT_ONLY) {
|
||||||
warn "unable to unlink $fullFileName: $!"
|
warn "unable to unlink $fullFileName: $!"
|
||||||
unless unlink("$fullFileName") == 1;
|
unless unlink("$fullFileName") == 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue