--- trunk/lib/WebPAC/Output/EstraierNative.pm 2006/09/11 20:26:01 672 +++ trunk/lib/WebPAC/Output/EstraierNative.pm 2006/09/11 20:49:37 673 @@ -11,6 +11,7 @@ use LWP; use URI::Escape; use List::Util qw/first/; +use File::Path; $Estraier::DEBUG = 1; @@ -21,11 +22,11 @@ =head1 VERSION -Version 0.1 +Version 0.2 =cut -our $VERSION = '0.1'; +our $VERSION = '0.2'; =head1 SYNOPSIS @@ -92,6 +93,15 @@ $self->{label} ||= "WebPAC $self->{database}"; my $path = 'casket'; + $path =~ s!/+$!!; + + $self->{_casket_path} = $path; + + $path .= '.tmp'; + if (-e $path) { + rmtree($path) || $log->logdie("can't remove old temporary directory $path: $!"); + } + mkpath($path) || $log->logdie("can't create new temporary directory $path: $!"); my $db = new Database(); unless($db->open($path, Database::DBWRITER | Database::DBCREAT)) { @@ -241,6 +251,34 @@ } +=head2 finish + +Close index and rename of to final path + + $est->finish; + +=cut + +sub finish { + my $self = shift; + + my $log = $self->_get_logger; + $log->info("closing Hyper Estraier index make it current..."); + + $self->{db}->close || $log->logdie("can't close index"); + + my $path = $self->{_casket_path} || $log->logdie("no _casket_path?"); + + if (-e $path) { + $log->warn("removing old $path"); + rmtree($path) || $log->logdie("can't remove old temporary directory $path: $!"); + } + + rename $path . '.tmp', $path || $log->logdie("can't rename ${path}.tmp -> $path: $!"); + +} + + =head2 convert my $utf8_string = $self->convert('string in codepage');