/[BackupPC]/trunk/bin/BackupPC_updatedb
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/bin/BackupPC_updatedb

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

revision 89 by dpavlin, Sun Aug 28 17:04:12 2005 UTC revision 97 by dpavlin, Tue Aug 30 09:55:55 2005 UTC
# Line 13  use File::Pid; Line 13  use File::Pid;
13  use POSIX qw/strftime/;  use POSIX qw/strftime/;
14    
15  use constant BPC_FTYPE_DIR => 5;  use constant BPC_FTYPE_DIR => 5;
16    use constant EST_SYNC_EVERY => 10000;
17    
18  my $debug = 0;  my $debug = 0;
19  $|=1;  $|=1;
# Line 85  sub curr_time { Line 86  sub curr_time {
86    
87  my $hest_db;  my $hest_db;
88    
89    sub signal {
90            my($sig) = @_;
91            if ($hest_db) {
92                    print "\nCaught a SIG$sig--syncing database and shutting down\n";
93                    $hest_db->sync();
94                    $hest_db->close();
95            }
96            exit(0);
97    }
98    
99    $SIG{'INT'}  = \&signal;
100    $SIG{'QUIT'} = \&signal;
101    
102  sub hest_update {  sub hest_update {
103    
104          my ($host_id, $share_id, $num) = @_;          my ($host_id, $share_id, $num) = @_;
105    
106          print curr_time," updating HyperEstraier: files";          print curr_time," updating HyperEstraier: select files";
107    
108          my $t = time();          my $t = time();
109    
# Line 113  sub hest_update { Line 127  sub hest_update {
127                          -- files.name                   AS filename,                          -- files.name                   AS filename,
128                          files.path                      AS filepath,                          files.path                      AS filepath,
129                          files.date                      AS date,                          files.date                      AS date,
130                          files.type                      AS filetype,                          files.type                      AS type,
131                          files.size                      AS size,                          files.size                      AS size,
132                          files.shareid                   AS shareid,                          files.shareid                   AS shareid,
133                          backups.date                    AS backup_date                          backups.date                    AS backup_date
# Line 128  sub hest_update { Line 142  sub hest_update {
142          my $results = $sth->rows;          my $results = $sth->rows;
143    
144          if ($results == 0) {          if ($results == 0) {
145                  print " no files\n";                  print " - no files, skipping\n";
146                  return;                  return;
147          }          }
148    
# Line 145  sub hest_update { Line 159  sub hest_update {
159    
160          my $max = int($results / $dot);          my $max = int($results / $dot);
161    
162          print " index $index_path...";          print ", opening index $index_path...";
163          use HyperEstraier;          use HyperEstraier;
164          my $db = HyperEstraier::Database->new();          my $db = HyperEstraier::Database->new();
165    
# Line 165  sub hest_update { Line 179  sub hest_update {
179                  my $fid = $row->{'fid'} || die "no fid?";                  my $fid = $row->{'fid'} || die "no fid?";
180                  my $uri = 'file:///' . $fid;                  my $uri = 'file:///' . $fid;
181    
182                  next if ($db->uri_to_id($uri));                  my $id = $db->uri_to_id($uri);
183                    next unless ($id == -1);
184    
185                  # create a document object                  # create a document object
186                  my $doc = HyperEstraier::Document->new;                  my $doc = HyperEstraier::Document->new;
# Line 196  sub hest_update { Line 211  sub hest_update {
211                          $max--;                          $max--;
212                  }                  }
213    
214                    if ($added % EST_SYNC_EVERY == 0) {
215                            print "sync ";
216                            $db->sync();
217                    }
218    
219          }          }
220    
221          print "sync $added new files";          print "sync $added new files";
222          $db->sync();          $db->sync();
223          print " close";          print ", close";
224          $db->close();          $db->close();
225    
226          my $dur = (time() - $t) || 1;          my $dur = (time() - $t) || 1;
# Line 215  sub hest_update { Line 235  sub hest_update {
235    
236    
237  ## update index ##  ## update index ##
238  if ($opt{i} || ($index_path && ! -e $index_path)) {  if (($opt{i} || ($index_path && ! -e $index_path)) && !$opt{c}) {
239          # update all          # update all
240          print "force update of HyperEstraier index ";          print "force update of HyperEstraier index ";
241          print "importing existing data" unless (-e $index_path);          print "importing existing data" unless (-e $index_path);

Legend:
Removed from v.89  
changed lines
  Added in v.97

  ViewVC Help
Powered by ViewVC 1.1.26