11 |
use LWP; |
use LWP; |
12 |
use URI::Escape; |
use URI::Escape; |
13 |
use List::Util qw/first/; |
use List::Util qw/first/; |
14 |
|
use File::Path; |
15 |
|
|
16 |
$Estraier::DEBUG = 1; |
$Estraier::DEBUG = 1; |
17 |
|
|
22 |
|
|
23 |
=head1 VERSION |
=head1 VERSION |
24 |
|
|
25 |
Version 0.1 |
Version 0.2 |
26 |
|
|
27 |
=cut |
=cut |
28 |
|
|
29 |
our $VERSION = '0.1'; |
our $VERSION = '0.2'; |
30 |
|
|
31 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
32 |
|
|
93 |
$self->{label} ||= "WebPAC $self->{database}"; |
$self->{label} ||= "WebPAC $self->{database}"; |
94 |
|
|
95 |
my $path = 'casket'; |
my $path = 'casket'; |
96 |
|
$path =~ s!/+$!!; |
97 |
|
|
98 |
|
$self->{_casket_path} = $path; |
99 |
|
|
100 |
|
$path .= '.tmp'; |
101 |
|
if (-e $path) { |
102 |
|
rmtree($path) || $log->logdie("can't remove old temporary directory $path: $!"); |
103 |
|
} |
104 |
|
mkpath($path) || $log->logdie("can't create new temporary directory $path: $!"); |
105 |
|
|
106 |
my $db = new Database(); |
my $db = new Database(); |
107 |
unless($db->open($path, Database::DBWRITER | Database::DBCREAT)) { |
unless($db->open($path, Database::DBWRITER | Database::DBCREAT)) { |
251 |
} |
} |
252 |
|
|
253 |
|
|
254 |
|
=head2 finish |
255 |
|
|
256 |
|
Close index and rename of to final path |
257 |
|
|
258 |
|
$est->finish; |
259 |
|
|
260 |
|
=cut |
261 |
|
|
262 |
|
sub finish { |
263 |
|
my $self = shift; |
264 |
|
|
265 |
|
my $log = $self->_get_logger; |
266 |
|
$log->info("closing Hyper Estraier index make it current..."); |
267 |
|
|
268 |
|
$self->{db}->close || $log->logdie("can't close index"); |
269 |
|
|
270 |
|
my $path = $self->{_casket_path} || $log->logdie("no _casket_path?"); |
271 |
|
|
272 |
|
if (-e $path) { |
273 |
|
$log->warn("removing old $path"); |
274 |
|
rmtree($path) || $log->logdie("can't remove old temporary directory $path: $!"); |
275 |
|
} |
276 |
|
|
277 |
|
rename $path . '.tmp', $path || $log->logdie("can't rename ${path}.tmp -> $path: $!"); |
278 |
|
|
279 |
|
} |
280 |
|
|
281 |
|
|
282 |
=head2 convert |
=head2 convert |
283 |
|
|
284 |
my $utf8_string = $self->convert('string in codepage'); |
my $utf8_string = $self->convert('string in codepage'); |