/[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 47 by dpavlin, Sat Aug 20 11:39:05 2005 UTC revision 48 by dpavlin, Sat Aug 20 14:13:58 2005 UTC
# Line 1  Line 1 
1  #!/usr/local/bin/perl -w  #!/usr/local/bin/perl -w
2    
3  use strict;  use strict;
 use DBI;  
4  use lib "__INSTALLDIR__/lib";  use lib "__INSTALLDIR__/lib";
5    
6    use DBI;
7  use BackupPC::Lib;  use BackupPC::Lib;
8  use BackupPC::View;  use BackupPC::View;
9  use Data::Dumper;  use Data::Dumper;
# Line 10  use Getopt::Std; Line 11  use Getopt::Std;
11  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
12  use File::Pid;  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    
17  my $debug = 0;  my $debug = 0;
# Line 280  sub getShareID() { Line 282  sub getShareID() {
282    
283  sub found_in_db {  sub found_in_db {
284    
285          my ($shareID,undef,$name,$path,undef,$date,undef,$size) = @_;          my @data = @_;
286            shift @data;
287    
288            my ($key, $shareID,undef,$name,$path,undef,$date,undef,$size) = @_;
289    
290            return $beenThere->{$key} if (defined($beenThere->{$key}));
291    
292          $sth->{file_in_db} ||= $dbh->prepare(qq{          $sth->{file_in_db} ||= $dbh->prepare(qq{
293                  SELECT count(*) FROM files                  SELECT 1 FROM files
294                  WHERE shareID = ? and                  WHERE shareID = ? and
295                          path = ? and                          path = ? and
296                          name = ? and                          name = ? and
# Line 293  sub found_in_db { Line 300  sub found_in_db {
300    
301          my @param = ($shareID,$path,$name,$date,$size);          my @param = ($shareID,$path,$name,$date,$size);
302          $sth->{file_in_db}->execute(@param);          $sth->{file_in_db}->execute(@param);
303          my ($rows) = $sth->{file_in_db}->fetchrow_array();          my $rows = $sth->{file_in_db}->rows;
304          print STDERR "## found_in_db ",( $rows ? '+' : '-' ), join(" ",@param), "\n" if ($debug >= 3);          print STDERR "## found_in_db ",( $rows ? '+' : '-' ), join(" ",@param), "\n" if ($debug >= 3);
305    
306            $beenThere->{$key}++;
307    
308            $sth->{'insert_files'}->execute(@data) unless ($rows);
309          return $rows;          return $rows;
310  }  }
311    
# Line 339  sub recurseDir($$$$$$$$) { Line 350  sub recurseDir($$$$$$$$) {
350                          ));                          ));
351    
352    
353                          if (! $beenThere->{$key} && ! found_in_db(@data)) {                          if (! defined($beenThere->{$key}) && ! found_in_db($key, @data)) {
354                                  print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2);                                  print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2);
355                                  $sth->{'insert_files'}->execute(@data);  
356                                  if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {                                  if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
357                                          $new_dirs++;                                          $new_dirs++;
358                                          print STDERR " dir\n" if ($debug >= 2);                                          print STDERR " dir\n" if ($debug >= 2);
# Line 350  sub recurseDir($$$$$$$$) { Line 361  sub recurseDir($$$$$$$$) {
361                                          print STDERR " file\n" if ($debug >= 2);                                          print STDERR " file\n" if ($debug >= 2);
362                                  }                                  }
363                          }                          }
                         $beenThere->{$key}++;  
364    
365                          if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {                          if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
366                                  $nr_dirs++;                                  $nr_dirs++;

Legend:
Removed from v.47  
changed lines
  Added in v.48

  ViewVC Help
Powered by ViewVC 1.1.26