You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by do...@apache.org on 2007/11/21 22:46:16 UTC
svn commit: r597217 - /spamassassin/trunk/masses/mass-check
Author: dos
Date: Wed Nov 21 13:46:15 2007
New Revision: 597217
URL: http://svn.apache.org/viewvc?rev=597217&view=rev
Log:
bug 5720: make sure that the first msg number we use is 1 and not 0; while we're at it, support (for correctness) the pretty unlikely case that we may want to cache messages located in the root directory
Modified:
spamassassin/trunk/masses/mass-check
Modified: spamassassin/trunk/masses/mass-check
URL: http://svn.apache.org/viewvc/spamassassin/trunk/masses/mass-check?rev=597217&r1=597216&r2=597217&view=diff
==============================================================================
--- spamassassin/trunk/masses/mass-check (original)
+++ spamassassin/trunk/masses/mass-check Wed Nov 21 13:46:15 2007
@@ -1401,7 +1401,7 @@
# we got a result, so assign it a number (curnum) and store the data
# appropriately, then add the new number to the queue.
- my $num = $msgsout->{'curnum'}++;
+ my $num = ++$msgsout->{'curnum'};
$msgsout->{$num}->{'data'} = $msg;
push(@tosend, $num);
}
@@ -1426,7 +1426,7 @@
# we got a result, so assign it a number (curnum) and store the data
# appropriately, then add the new number to the queue.
- my $num = $msgsout->{'curnum'}++;
+ my $num = ++$msgsout->{'curnum'};
$msgsout->{$num}->{'data'} = $server_caches{'to_process'}{$path};
push(@tosend, [ $num, 1 ]);
delete $server_caches{'to_process'}{$path};
@@ -1443,7 +1443,7 @@
(my($path, undef) = each %{$server_caches{'not_cached'}})) {
# we got a result, so assign it a number (curnum) and store the data
# appropriately, then add the new number to the queue.
- my $num = $msgsout->{'curnum'}++;
+ my $num = ++$msgsout->{'curnum'};
$msgsout->{$num}->{'data'} = $server_caches{'to_process'}{$path};
push(@tosend, [ $num, 0 ]);
delete $server_caches{'to_process'}{$path};
@@ -1457,7 +1457,7 @@
(my($path, undef) = each %{$client_caches{$client_id}})) {
# we got a result, so assign it a number (curnum) and store the data
# appropriately, then add the new number to the queue.
- my $num = $msgsout->{'curnum'}++;
+ my $num = ++$msgsout->{'curnum'};
$msgsout->{$num}->{'data'} = $server_caches{'to_process'}{$path};
push(@tosend, [ $num, 1 ]);
delete $server_caches{'to_process'}{$path};
@@ -1481,7 +1481,7 @@
(my($path, $msg) = each %{$server_caches{'to_process'}})) {
# we got a result, so assign it a number (curnum) and store the data
# appropriately, then add the new number to the queue.
- my $num = $msgsout->{'curnum'}++;
+ my $num = ++$msgsout->{'curnum'};
$msgsout->{$num}->{'data'} = $server_caches{'to_process'}{$path};
push(@tosend, [ $num, 0 ]);
delete $server_caches{'to_process'}{$path};
@@ -2327,23 +2327,23 @@
# TODO: the entire mass-check script should probably use umask 0077;
mkdir $opt_cs_cachedir; # mkdir won't bitch if it already exists, that's ok
- if (-d $opt_cs_cachedir && $d[3] =~ m{^/?(.*(?![^\\]\\)/)(.+)$}) {
+ if (-d $opt_cs_cachedir && $d[3] =~ m{^/?(.*(?![^\\]\\)/)?(.+)$}) {
my ($path, $filename) = ($1, $2);
my $dir = '';
+ $path ||= '';
while ($path =~ m#((?![^\\]\\)[^/]+/)#gc) {
$dir .= $1;
mkdir "$opt_cs_cachedir/$dir";
}
- chop $dir; # chop the trailing slash to make the following code more readable
if (-d "$opt_cs_cachedir/$dir") {
- if (open(OUT, ">$opt_cs_cachedir/$dir/$filename")) {
+ if (open(OUT, ">$opt_cs_cachedir/$dir$filename")) {
print OUT $msg;
close $msg;
$cache_success = 1;
}
else {
- warn "Can't create/write message cache file $opt_cs_cachedir/$dir/$filename: $!";
+ warn "Can't create/write message cache file $opt_cs_cachedir/$dir$filename: $!";
}
}
}
@@ -2396,14 +2396,14 @@
# TODO: the entire mass-check script should probably use umask 0077;
mkdir $opt_cs_cachedir; # mkdir won't bitch if it already exists, that's ok
- if (-d $opt_cs_cachedir && $d[3] =~ m{^/?(.*(?![^\\]\\)/)(.+)$}) {
+ if (-d $opt_cs_cachedir && $d[3] =~ m{^/?(.*(?![^\\]\\)/)?(.+)$}) {
my ($path, $filename) = ($1, $2);
my $dir = '';
+ $path ||= '';
while ($path =~ m#((?![^\\]\\)[^/]+/)#gc) {
$dir .= $1;
mkdir "$opt_cs_cachedir/$dir";
}
- chop $dir; # chop the trailing slash to make the following code more readable
if (-d "$opt_cs_cachedir/$dir") {
# copy the file to the local cache for use next (and this) time
if (copy($d[3], "$opt_cs_cachedir/$d[3]")) {