/[webpac2]/trunk/lib/WebPAC/Output/EstraierNative.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Output/EstraierNative.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 630 by dpavlin, Wed Sep 6 14:25:05 2006 UTC revision 782 by dpavlin, Sun Nov 5 16:51:49 2006 UTC
# Line 11  use Data::Dumper; Line 11  use Data::Dumper;
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    
# Line 21  WebPAC::Output::EstraierNative - Create Line 22  WebPAC::Output::EstraierNative - Create
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    
# Line 92  sub new { Line 93  sub new {
93          $self->{label} ||= "WebPAC $self->{database}";          $self->{label} ||= "WebPAC $self->{database}";
94    
95          my $path = 'casket';          my $path = 'casket';
96            $path =~ s!/+$!!;
97    
98            $path .= '/' . $self->{database};
99    
100            $self->{path} = $path;
101    
102            $path .= '.tmp';
103            if (-e $path) {
104                    rmtree($path) || $log->logdie("can't remove old temporary directory $path: $!");
105            }
106            mkpath($path) || $log->logdie("can't create new temporary directory $path: $!");
107    
108          my $db = new Database();          my $db = new Database();
109          unless($db->open($path, Database::DBWRITER | Database::DBCREAT)) {          unless($db->open($path, Database::DBWRITER | Database::DBCREAT)) {
# Line 189  sub add { Line 201  sub add {
201          }          }
202    
203          $log->debug("adding ", sub { $doc->dump_draft } );          $log->debug("adding ", sub { $doc->dump_draft } );
204          $self->{'db'}->put_doc($doc, Database::PDCLEAN) || $log->warn("can't add document $uri with draft " . $doc->dump_draft . " to node " . $self->{path} . " status: " . $self->{db}->status());          $self->{'db'}->put_doc($doc, Database::PDCLEAN) || $log->warn("can't add document $uri with draft " . $doc->dump_draft . " to node " . $self->{path} . " status: " . $self->{db}->error());
205    
206          return 1;          return 1;
207  }  }
# Line 241  sub add_link { Line 253  sub add_link {
253  }  }
254    
255    
256    =head2 finish
257    
258    Close index and rename of to final path
259    
260            $est->finish;
261    
262    =cut
263    
264    sub finish {
265            my $self = shift;
266    
267            my $log = $self->_get_logger;
268            $log->info("closing Hyper Estraier index make it current...");
269    
270            $self->{db}->close || $log->logdie("can't close index");
271    
272            my $path = $self->{path} || $log->logdie("no path?");
273    
274            if (-e $path) {
275                    $log->warn("removing old $path");
276                    rmtree($path) || $log->logdie("can't remove old temporary directory $path: $!");
277            }
278    
279            rename $path . '.tmp', $path || $log->logdie("can't rename ${path}.tmp -> $path: $!");
280    
281    }
282    
283    
284  =head2 convert  =head2 convert
285    
286   my $utf8_string = $self->convert('string in codepage');   my $utf8_string = $self->convert('string in codepage');

Legend:
Removed from v.630  
changed lines
  Added in v.782

  ViewVC Help
Powered by ViewVC 1.1.26