use File::Spec::Functions;
use Config::General;
use File::Basename;
+use File::Copy;
use Cwd qw( abs_path );
use Data::Dumper;
use Getopt::Long;
my $l = $config->{'lookup'}{$lookup};
my $sql = $l->{'query'};
- my $type = $l->{'type'} || $default_database_type;
+ my $type = lc($l->{'type'}) || $default_database_type;
my $map_type = 'map';
$map_type = 'aliases' if $l->{'map_type'} =~ /^\s*alias(?:es)?\s*$/;
unless ( $sql ) {
}
$max_length += 1 if $map_type eq 'aliases';
- my $new_file = catfile( $workdir, $lookup . ".new" );
+ my $new_file = catfile( $workdir, $lookup );
+ my $cur_file = catfile( $lookup_dir, $lookup );
debug( 1, "Schreibe Ergebnisse in Datei '" . $new_file . "' ..." );
unless ( open FILE, ">", $new_file ) {
close FILE;
+ my $changed = 0;
+
+ $changed = 1 unless -f $cur_file;
+
+ if ( $changed ) {
+
+ debug( 0, "Aktualisiere Lookup-Tabelle '" . $lookup . "'." );
+ debug( 1, "Kopiere '" . $new_file . "' nach '" . $cur_file . "' ..." );
+ copy $new_file, $cur_file;
+
+ if ( $type eq 'btree' or $type eq 'dbm' or $type eq 'hash' ) {
+ my $cmd = $map_type eq 'aliases' ? $binary->{'postalias'} : $binary->{'postmap'};
+ my @Args = ( $cmd, $type . ":" . $cur_file );
+ debug( 1, 'Führe Kommando aus: ', join( " ", @Args ) );
+ unless ( system(@Args) == 0 ) {
+ fatal( "Fehler beim Ausführen von '" . join( ' ', @Args ) . "'." );
+ }
+ }
+ else {
+ $do_postfix_reload = 1;
+ }
+
+ }
+
}
#--------------------------------------------------------------------------------------