[Koha-patches] [PATCH] Fix for problems in previous zebraidx patch
Jesse Weaver
jesse.weaver at liblime.com
Tue Oct 7 01:28:32 CEST 2008
This fixes some logic errors in the skip-commit patch for zebraidx.
---
misc/migration_tools/rebuild_zebra.pl | 39 ++++++++++++++++++++------------
1 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl
index c6d0adc..83646a0 100755
--- a/misc/migration_tools/rebuild_zebra.pl
+++ b/misc/migration_tools/rebuild_zebra.pl
@@ -5,6 +5,7 @@ use strict;
use C4::Context;
use Getopt::Long;
use File::Temp qw/ tempdir /;
+use POSIX;
use File::Path;
use File::Spec;
use C4::Biblio;
@@ -197,11 +198,10 @@ sub index_records {
my $zebra_server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
my $del_success = 1;
my $upd_success = 1;
+ my $index_age = get_index_age($zebra_server);
+ my $dbh = C4::Context->dbh;
if ($process_zebraqueue) {
- my $index_age = get_index_age($zebra_server);
- my $dbh = C4::Context->dbh;
-
$del_success = do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $skip_commit, $record_fmt, $zebraidx_log_opt)
if $num_records_deleted;
$upd_success = do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $skip_commit, $record_fmt, $zebraidx_log_opt)
@@ -212,13 +212,23 @@ sub index_records {
}
if (!$del_success || !$upd_success) {
- my $sth = $dbh->prepare('
- UPDATE zebraqueue
- SET done = 0
- WHERE done = 1 AND time >= ?
- ');
+ if (!$del_success) {
+ my $sth = $dbh->prepare('
+ UPDATE zebraqueue
+ SET done = 0
+ WHERE done = 1 AND time >= ? AND operation = "recordDelete"
+ ');
+ $sth->execute($index_age);
+ }
- $sth->execute($index_age);
+ if (!$upd_success) {
+ my $sth = $dbh->prepare('
+ UPDATE zebraqueue
+ SET done = 0
+ WHERE done = 1 AND time >= ? AND operation = "specialUpdate"
+ ');
+ $sth->execute($index_age);
+ }
cleanup();
die "Indexing failed";
@@ -547,7 +557,7 @@ sub get_index_age {
# If zebraqueue has not yet been processed, default to today at midnight
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
- $last_done = strftime('%Y-%m-%d %H:%M:%S', 0, 0, 0, $mday, $mon, $year);
+ $last_done = POSIX::strftime('%Y-%m-%d %H:%M:%S', 0, 0, 0, $mday, $mon, $year);
}
set_index_age($zebra_server, $last_done);
@@ -581,8 +591,6 @@ sub do_indexing {
return if ($commit_error);
- set_index_age($zebra_server, strftime('%Y-%m-%d %H:%M:%S', localtime(time))) unless ($skip_commit); # Indexing errors handled above
-
return 1;
}
@@ -620,7 +628,7 @@ Parameters:
already exported the records
in a previous run.
- -s Skip commit. Skips committing the
+ -c Skip commit. Skips committing the
Zebra shadow files to the index, helping
speed.
@@ -629,8 +637,9 @@ Parameters:
option is recommended only
for advanced user.
- -x export and index as xml instead of is02709 (biblios only).
- use this if you might have records > 99,999 chars,
+ -x export and index as xml instead of iso2709 (biblios
+ only). use this if you might have records > 99,999
+ chars.
-w skip shadow indexing for this batch
--
1.5.5.GIT
More information about the Koha-patches
mailing list