be chatty on debug level 3
[BackupPC.git] / bin / BackupPC_updatedb
index 1b254b2..b052b33 100755 (executable)
@@ -52,8 +52,7 @@ my $beenThere = {};
 my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n";
 my $user = $Conf{SearchUser} || '';
 
-my $use_hest = $Conf{HyperEstraierIndex};
-my ($index_path, $index_node_url) = BackupPC::SearchLib::getHyperEstraier_url($use_hest);
+my $index_node_url = $Conf{HyperEstraierIndex};
 
 my $dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 0 });
 
@@ -87,7 +86,7 @@ if ($opt{v}) {
        $debug = $opt{v};
 } elsif ($opt{f}) {
        print "WARNING: disabling full-text index update. You need to re-run $0 -j !\n";
-       ($use_hest, $index_path, $index_node_url) = (undef, undef, undef);
+       $index_node_url = undef;
 }
 
 #---- subs ----
@@ -127,34 +126,27 @@ sub hest_update {
 
        my $skip_check = $opt{j} && print STDERR "Skipping check for existing files -- this should be used only with initital import\n";
 
-       unless (defined($use_hest)) {
+       unless (defined($index_node_url)) {
                print STDERR "HyperEstraier support not enabled in configuration\n";
-               $use_hest = 0;
+               $index_node_url = 0;
                return;
        }
 
-       return unless($use_hest);
-
-       print curr_time," updating HyperEstraier:";
+       print curr_time," updating Hyper Estraier:";
 
        my $t = time();
 
        my $offset = 0;
        my $added = 0;
 
-       print " opening index $use_hest";
-       if ($index_path) {
-               $hest_db = HyperEstraier::Database->new();
-               $hest_db->open($TopDir . $index_path, $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT);
-               print " directly";
-       } elsif ($index_node_url) {
-               $hest_node ||= HyperEstraier::Node->new($index_node_url);
+       print " opening index $index_node_url";
+       if ($index_node_url) {
+               $hest_node ||= Search::Estraier::Node->new($index_node_url);
                $hest_node->set_auth('admin', 'admin');
                print " via node URL";
        } else {
-               die "don't know how to use HyperEstraier Index $use_hest";
+               die "don't know how to use Hyper Estraier Index $index_node_url";
        }
-       print " increment is " . EST_CHUNK . " files:";
 
        my $results = 0;
 
@@ -202,6 +194,8 @@ sub hest_update {
                if ($results == 0) {
                        print " - no new files\n";
                        last;
+               } else {
+                       print " - $results files: ";
                }
 
                sub fmt_date {
@@ -222,12 +216,13 @@ sub hest_update {
                        }
 
                        # create a document object 
-                       my $doc = HyperEstraier::Document->new;
+                       my $doc = Search::Estraier::Document->new;
 
                        # add attributes to the document object 
                        $doc->add_attr('@uri', $uri);
 
                        foreach my $c (@{ $sth->{NAME} }) {
+                               print STDERR "attr $c = $row->{$c}\n" if ($debug > 2);
                                $doc->add_attr($c, $row->{$c}) if (defined($row->{$c}));
                        }
 
@@ -242,9 +237,7 @@ sub hest_update {
                        print STDERR $doc->dump_draft,"\n" if ($debug > 1);
 
                        # register the document object to the database
-                       if ($hest_db) {
-                               $hest_db->put_doc($doc, $HyperEstraier::Database::PDCLEAN);
-                       } elsif ($hest_node) {
+                       if ($hest_node) {
                                $hest_node->put_doc($doc);
                        } else {
                                die "not supported";
@@ -253,17 +246,11 @@ sub hest_update {
                }
 
                print " $added";
-               $hest_db->sync() if ($index_path);
 
                $offset += EST_CHUNK;
 
        } while ($results == EST_CHUNK);
 
-       if ($index_path) {
-               print ", close";
-               $hest_db->close();
-       }
-
        my $dur = (time() - $t) || 1;
        printf(" [%.2f/s dur: %s]\n",
                ( $added / $dur ),
@@ -275,10 +262,9 @@ sub hest_update {
 
 
 ## update index ##
-if (($opt{i} || $opt{j} || ($index_path && ! -e $TopDir . $index_path)) && !$opt{c}) {
+if ( ( $opt{i} || $opt{j} ) && !$opt{c} ) {
        # update all
-       print "force update of HyperEstraier index ";
-       print "importing existing data" unless (-e $TopDir . $index_path);
+       print "force update of Hyper Estraier index ";
        print "by -i flag" if ($opt{i});
        print "by -j flag" if ($opt{j});
        print "\n";