/[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 98 by dpavlin, Tue Aug 30 14:19:54 2005 UTC revision 114 by dpavlin, Sun Sep 11 11:48:16 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_CHUNK => 10000;  use constant EST_CHUNK => 100000;
17    
18  my $debug = 0;  my $debug = 0;
19  $|=1;  $|=1;
# Line 42  my $beenThere = {}; Line 42  my $beenThere = {};
42  my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n";  my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n";
43  my $user = $Conf{SearchUser} || '';  my $user = $Conf{SearchUser} || '';
44  my $index_path = $Conf{HyperEstraierIndex};  my $index_path = $Conf{HyperEstraierIndex};
 $index_path = $TopDir . '/' . $index_path;  
 $index_path =~ s#//#/#g;  
45  if ($index_path) {  if ($index_path) {
46            $index_path = $TopDir . '/' . $index_path;
47            $index_path =~ s#//#/#g;
48          use HyperEstraier;          use HyperEstraier;
49  }  }
50    
# Line 117  sub hest_update { Line 117  sub hest_update {
117          $hest_db = HyperEstraier::Database->new();          $hest_db = HyperEstraier::Database->new();
118          $hest_db->open($index_path, $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT);          $hest_db->open($index_path, $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT);
119    
120            print " increment is " . EST_CHUNK . " files:";
121    
122          my $results = 0;          my $results = 0;
123    
124          do {          do {
125    
126                  my $where = '';                  my $where = '';
127                    my @data;
128                  if ($host_id && $share_id && $num) {                  if ($host_id && $share_id && $num) {
129                          $where = qq{                          $where = qq{
130                          WHERE                          WHERE
# Line 129  sub hest_update { Line 132  sub hest_update {
132                                  shares.id = ? AND                                  shares.id = ? AND
133                                  files.backupnum = ?                                  files.backupnum = ?
134                          };                          };
135                            @data = ( $host_id, $share_id, $num );
136                  }                  }
137    
138                  my $limit = sprintf('LIMIT '.EST_CHUNK.' OFFSET %d', $offset);                  my $limit = sprintf('LIMIT '.EST_CHUNK.' OFFSET %d', $offset);
# Line 155  sub hest_update { Line 159  sub hest_update {
159                          $limit                          $limit
160                  });                  });
161    
162                  $sth->execute(@_);                  $sth->execute(@data);
163                  $results = $sth->rows;                  $results = $sth->rows;
164    
165                  if ($results == 0) {                  if ($results == 0) {
166                          print " - no more files\n";                          print " - no new files\n";
167                          last;                          last;
168                  }                  }
169    
# Line 448  foreach my $host_key (keys %{$hosts}) { Line 452  foreach my $host_key (keys %{$hosts}) {
452                                  fmt_time($dur)                                  fmt_time($dur)
453                          );                          );
454    
455                          hest_update($hostID, $shareID, $backupNum);                          hest_update($hostID, $shareID, $backupNum) if ($nf + $nd > 0);
456                  }                  }
457    
458          }          }

Legend:
Removed from v.98  
changed lines
  Added in v.114

  ViewVC Help
Powered by ViewVC 1.1.26