my $installer = C4::Installer->new();
my %info;
-$info{'dbname'} = C4::Context->config("database");
+$info{'dbname'} = C4::Context->config("database_test") || C4::Context->config("database");
$info{'dbms'} = (
C4::Context->config("db_scheme")
? C4::Context->config("db_scheme")
my $dir =
C4::Context->config('intranetdir')
. "/installer/data/$info{dbms}/$langchoice/marcflavour";
- unless ( opendir( MYDIR, $dir ) ) {
+ my $dir_h;
+ unless ( opendir( $dir_h, $dir ) ) {
if ( $langchoice eq 'en' ) {
warn "cannot open MARC frameworks directory $dir";
}
# default to English
$dir = C4::Context->config('intranetdir')
. "/installer/data/$info{dbms}/en/marcflavour";
- opendir( MYDIR, $dir )
+ opendir( $dir_h, $dir )
or warn "cannot open English MARC frameworks directory $dir";
}
}
- my @listdir = grep { !/^\./ && -d "$dir/$_" } readdir(MYDIR);
- closedir MYDIR;
+ my @listdir = grep { !/^\./ && -d "$dir/$_" } readdir($dir_h);
+ closedir $dir_h;
my $marcflavour = C4::Context->preference("marcflavour");
my @flavourlist;
foreach my $marc (@listdir) {
or die "Cannot open log file $logfilepath_errors: $!";
@report = <$fh>;
close $fh;
+ my $update_errors;
if (@report) {
$template->param( update_errors =>
[ map { { line => $_ } } split( /\n/, join( '', @report ) ) ]
);
+ $update_errors = 1;
$template->param( has_update_errors => 1 );
warn
"The following errors were returned while attempting to run the updatedatabase.pl script:\n";
eval { `rm $logfilepath_errors` };
}
- my $db_entries = get_db_entries();
- my $report = update( $db_entries );
-
- $template->param( success => $report->{success}, error => $report->{error} );
+ unless ( $update_errors ) {
+ my $db_entries = get_db_entries();
+ my $report = update( $db_entries );
+ my $atomic_update_files = get_atomic_updates;
+ my $atomic_update_report = run_atomic_updates( $atomic_update_files );
+
+ $template->param(
+ success => $report->{success},
+ error => $report->{error},
+ atomic_updates => {
+ success => $atomic_update_report->{success},
+ error => $atomic_update_report->{error}
+ }
+ );
+ }
- #warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; #FIXME restore this
$template->param( $op => 1 );
}
else {