Fix badly ordered check on squid log file to parse. Thanks to wordelle for the report.

This commit is contained in:
Darold Gilles 2013-05-29 18:14:41 +02:00
parent 5bc0268ce7
commit 3ab029534b
1 changed files with 6 additions and 9 deletions

View File

@ -430,9 +430,6 @@ sub _init
}
my %options = &parse_config($conf_file, $log_file, $rebuild);
# Use squid log file given as command line parameter
$options{LogFile} = $log_file if ($log_file);
# Configuration options
$self->{MinPie} = $options{MinPie} || 2;
$self->{QuietMode} = $options{QuietMode} || 0;
@ -471,9 +468,6 @@ sub _init
if (!$self->{LogFile}) {
die "ERROR: 'LogFile' configuration option must be set.\n";
}
if (!$rebuild && ! -e $self->{LogFile}) {
die "ERROR: 'LogFile' $self->{LogFile} doesn't exists.\n";
}
$self->{OrderUser} = lc($options{OrderUser}) || 'bytes';
$self->{OrderNetwork} = lc($options{OrderNetwork}) || 'bytes';
$self->{OrderUrl} = lc($options{OrderUrl}) || 'bytes';
@ -2989,14 +2983,17 @@ sub parse_config
}
close(CONF);
# Set logfile from command line if any.
$opt{LogFile} = $log_file if ($log_file);
# Check config
if (!exists $opt{Output} || !-d $opt{Output}) {
print STDERR "Error: you must give a valid output directory. See option: Output\n";
exit 0;
}
if (!$rebuild || $log_file) {
if (!$log_file && (!exists $opt{LogFile} || !-f $opt{LogFile})) {
print STDERR "Error: you must give the path to the Squid log file. See option: LogFile\n";
if ( !$opt{LogFile} || !-f $opt{LogFile} ) {
if (!$rebuild) {
print STDERR "Error: you must give a valid path to the Squid log file. See LogFile or option -l\n";
exit 0;
}
}