/[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 136 by dpavlin, Fri Sep 23 15:04:37 2005 UTC revision 306 by dpavlin, Sat Jan 28 20:42:42 2006 UTC
# Line 12  use Time::HiRes qw/time/; Line 12  use Time::HiRes qw/time/;
12  use File::Pid;  use File::Pid;
13  use POSIX qw/strftime/;  use POSIX qw/strftime/;
14  use BackupPC::SearchLib;  use BackupPC::SearchLib;
15    use Cwd qw/abs_path/;
16    
17  use constant BPC_FTYPE_DIR => 5;  use constant BPC_FTYPE_DIR => 5;
18  use constant EST_CHUNK => 100000;  use constant EST_CHUNK => 100000;
19    
20    # daylight saving time change offset for 1h
21    my $dst_offset = 60 * 60;
22    
23  my $debug = 0;  my $debug = 0;
24  $|=1;  $|=1;
25    
26  my $start_t = time();  my $start_t = time();
27    
28  my $pidfile = new File::Pid;  my $pid_path = abs_path($0);
29    $pid_path =~ s/\W+/_/g;
30    
31    my $pidfile = new File::Pid({
32            file => "/tmp/$pid_path",
33    });
34    
35  if (my $pid = $pidfile->running ) {  if (my $pid = $pidfile->running ) {
36          die "$0 already running: $pid\n";          die "$0 already running: $pid\n";
# Line 29  if (my $pid = $pidfile->running ) { Line 38  if (my $pid = $pidfile->running ) {
38          $pidfile->remove;          $pidfile->remove;
39          $pidfile = new File::Pid;          $pidfile = new File::Pid;
40  }  }
 $pidfile->write;  
41  print STDERR "$0 using pid ",$pidfile->pid," file ",$pidfile->file,"\n";  print STDERR "$0 using pid ",$pidfile->pid," file ",$pidfile->file,"\n";
42    $pidfile->write;
43    
44  my $t_fmt = '%Y-%m-%d %H:%M:%S';  my $t_fmt = '%Y-%m-%d %H:%M:%S';
45    
# Line 43  my $beenThere = {}; Line 52  my $beenThere = {};
52  my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n";  my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n";
53  my $user = $Conf{SearchUser} || '';  my $user = $Conf{SearchUser} || '';
54    
55  my $use_hest = $Conf{HyperEstraierIndex};  my $index_node_url = $Conf{HyperEstraierIndex};
 my ($index_path, $index_node_url) = BackupPC::SearchLib::getHyperEstraier_url($use_hest);  
56    
57  my $dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 0 });  my $dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 0 });
58    
59  my %opt;  my %opt;
60    
61  if ( !getopts("cdm:v:ij", \%opt ) ) {  if ( !getopts("cdm:v:ijf", \%opt ) ) {
62          print STDERR <<EOF;          print STDERR <<EOF;
63  usage: $0 [-c|-d] [-m num] [-v|-v level] [-i]  usage: $0 [-c|-d] [-m num] [-v|-v level] [-i|-j|-f]
64    
65  Options:  Options:
66          -c      create database on first use          -c      create database on first use
# Line 61  Options: Line 69  Options:
69          -v num  set verbosity (debug) level (default $debug)          -v num  set verbosity (debug) level (default $debug)
70          -i      update Hyper Estraier full text index          -i      update Hyper Estraier full text index
71          -j      update full text, don't check existing files          -j      update full text, don't check existing files
72            -f      don't do anything with full text index
73    
74  Option -j is variation on -i. It will allow faster initial creation  Option -j is variation on -i. It will allow faster initial creation
75  of full-text index from existing database.  of full-text index from existing database.
76    
77    Option -f will create database which is out of sync with full text index. You
78    will have to re-run $0 with -i to fix it.
79    
80  EOF  EOF
81          exit 1;          exit 1;
82  }  }
# Line 72  EOF Line 84  EOF
84  if ($opt{v}) {  if ($opt{v}) {
85          print "Debug level at $opt{v}\n";          print "Debug level at $opt{v}\n";
86          $debug = $opt{v};          $debug = $opt{v};
87    } elsif ($opt{f}) {
88            print "WARNING: disabling full-text index update. You need to re-run $0 -j !\n";
89            $index_node_url = undef;
90  }  }
91    
92  #---- subs ----  #---- subs ----
# Line 89  sub curr_time { Line 104  sub curr_time {
104          return strftime($t_fmt,localtime());          return strftime($t_fmt,localtime());
105  }  }
106    
 my $hest_db;  
107  my $hest_node;  my $hest_node;
108    
 sub signal {  
         my($sig) = @_;  
         if ($hest_db) {  
                 print "\nCaught a SIG$sig--syncing database and shutting down\n";  
                 $hest_db->sync();  
                 $hest_db->close();  
         }  
         exit(0);  
 }  
   
 $SIG{'INT'}  = \&signal;  
 $SIG{'QUIT'} = \&signal;  
   
109  sub hest_update {  sub hest_update {
110    
111          my ($host_id, $share_id, $num) = @_;          my ($host_id, $share_id, $num) = @_;
112    
113          my $skip_check = $opt{j} && print STDERR "Skipping check for existing files -- this should be used only with initital import\n";          my $skip_check = $opt{j} && print STDERR "Skipping check for existing files -- this should be used only with initital import\n";
114    
115          unless ($use_hest) {          unless (defined($index_node_url)) {
116                  print STDERR "HyperEstraier support not enabled in configuration\n";                  print STDERR "HyperEstraier support not enabled in configuration\n";
117                    $index_node_url = 0;
118                  return;                  return;
119          }          }
120    
121          print curr_time," updating HyperEstraier:";          print curr_time," updating Hyper Estraier:";
122    
123          my $t = time();          my $t = time();
124    
125          my $offset = 0;          my $offset = 0;
126          my $added = 0;          my $added = 0;
127    
128          print " opening index $use_hest";          print " opening index $index_node_url";
129          if ($index_path) {          if ($index_node_url) {
130                  $hest_db = HyperEstraier::Database->new();                  $hest_node ||= Search::Estraier::Node->new(
131                  $hest_db->open($TopDir . $index_path, $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT);                          url => $index_node_url,
132                  print " directly";                          user => 'admin',
133          } elsif ($index_node_url) {                          passwd => 'admin',
134                  $hest_node ||= HyperEstraier::Node->new($index_node_url);                          croak_on_error => 1,
135                  $hest_node->set_auth('admin', 'admin');                  );
136                  print " via node URL";                  print " via node URL";
137          } else {          } else {
138                  die "don't know how to use HyperEstraier Index $use_hest";                  die "don't know how to use Hyper Estraier Index $index_node_url";
139          }          }
         print " increment is " . EST_CHUNK . " files:";  
140    
141          my $results = 0;          my $results = 0;
142    
# Line 143  sub hest_update { Line 144  sub hest_update {
144    
145                  my $where = '';                  my $where = '';
146                  my @data;                  my @data;
147                  if ($host_id && $share_id && $num) {                  if (defined($host_id) && defined($share_id) && defined($num)) {
148                          $where = qq{                          $where = qq{
149                          WHERE                          WHERE
150                                  hosts.id = ? AND                                  hosts.id = ? AND
# Line 182  sub hest_update { Line 183  sub hest_update {
183    
184                  if ($results == 0) {                  if ($results == 0) {
185                          print " - no new files\n";                          print " - no new files\n";
186                          last;                          return;
187                    } else {
188                            print " - $results files: ";
189                  }                  }
190    
191                  sub fmt_date {                  sub fmt_date {
# Line 198  sub hest_update { Line 201  sub hest_update {
201                          my $uri = 'file:///' . $fid;                          my $uri = 'file:///' . $fid;
202    
203                          unless ($skip_check) {                          unless ($skip_check) {
204                                  my $id = ($hest_db || $hest_node)->uri_to_id($uri);                                  my $id = $hest_node->uri_to_id($uri);
205                                  next unless ($id == -1);                                  next if ($id && $id == -1);
206                          }                          }
207    
208                          # create a document object                          # create a document object
209                          my $doc = HyperEstraier::Document->new;                          my $doc = Search::Estraier::Document->new;
210    
211                          # add attributes to the document object                          # add attributes to the document object
212                          $doc->add_attr('@uri', $uri);                          $doc->add_attr('@uri', $uri);
213    
214                          foreach my $c (@{ $sth->{NAME} }) {                          foreach my $c (@{ $sth->{NAME} }) {
215                                  $doc->add_attr($c, $row->{$c}) if ($row->{$c});                                  print STDERR "attr $c = $row->{$c}\n" if ($debug > 2);
216                                    $doc->add_attr($c, $row->{$c}) if (defined($row->{$c}));
217                          }                          }
218    
219                          #$doc->add_attr('@cdate', fmt_date($row->{'date'}));                          #$doc->add_attr('@cdate', fmt_date($row->{'date'}));
# Line 223  sub hest_update { Line 227  sub hest_update {
227                          print STDERR $doc->dump_draft,"\n" if ($debug > 1);                          print STDERR $doc->dump_draft,"\n" if ($debug > 1);
228    
229                          # register the document object to the database                          # register the document object to the database
230                          if ($hest_db) {                          if ($hest_node) {
                                 $hest_db->put_doc($doc, $HyperEstraier::Database::PDCLEAN);  
                         } elsif ($hest_node) {  
231                                  $hest_node->put_doc($doc);                                  $hest_node->put_doc($doc);
232                          } else {                          } else {
233                                  die "not supported";                                  die "not supported";
# Line 234  sub hest_update { Line 236  sub hest_update {
236                  }                  }
237    
238                  print " $added";                  print " $added";
                 $hest_db->sync() if ($index_path);  
239    
240                  $offset += EST_CHUNK;                  $offset += EST_CHUNK;
241    
242          } while ($results == EST_CHUNK);          } while ($results == EST_CHUNK);
243    
         if ($index_path) {  
                 print ", close";  
                 $hest_db->close();  
         }  
   
244          my $dur = (time() - $t) || 1;          my $dur = (time() - $t) || 1;
245          printf(" [%.2f/s dur: %s]\n",          printf(" [%.2f/s dur: %s]\n",
246                  ( $added / $dur ),                  ( $added / $dur ),
# Line 256  sub hest_update { Line 252  sub hest_update {
252    
253    
254  ## update index ##  ## update index ##
255  if (($opt{i} || $opt{j} || ($index_path && ! -e $index_path)) && !$opt{c}) {  if ( ( $opt{i} || $opt{j} ) && !$opt{c} ) {
256          # update all          # update all
257          print "force update of HyperEstraier index ";          print "force update of Hyper Estraier index ";
         print "importing existing data" unless (-e $index_path);  
258          print "by -i flag" if ($opt{i});          print "by -i flag" if ($opt{i});
259          print "by -j flag" if ($opt{j});          print "by -j flag" if ($opt{j});
260          print "\n";          print "\n";
# Line 270  if (($opt{i} || $opt{j} || ($index_path Line 265  if (($opt{i} || $opt{j} || ($index_path
265  if ($opt{c}) {  if ($opt{c}) {
266          sub do_index {          sub do_index {
267                  my $index = shift || return;                  my $index = shift || return;
268                  my ($table,$col,$unique) = split(/_/, $index);                  my ($table,$col,$unique) = split(/:/, $index);
269                  $unique ||= '';                  $unique ||= '';
270                  $index =~ s/,/_/g;                  $index =~ s/\W+/_/g;
271                    print "$index on $table($col)" . ( $unique ? "u" : "" ) . " ";
272                  $dbh->do(qq{ create $unique index $index on $table($col) });                  $dbh->do(qq{ create $unique index $index on $table($col) });
273          }          }
274    
275          print "creating tables...\n";          print "creating tables...\n";
276          
277          $dbh->do(qq{          $dbh->do( qq{
278                  create table hosts (                  create table hosts (
279                          ID      SERIAL          PRIMARY KEY,                          ID      SERIAL          PRIMARY KEY,
280                          name    VARCHAR(30)     NOT NULL,                          name    VARCHAR(30)     NOT NULL,
281                          IP      VARCHAR(15)                          IP      VARCHAR(15)
282                  );                              );            
283          });  
                 
         $dbh->do(qq{  
284                  create table shares (                  create table shares (
285                          ID      SERIAL          PRIMARY KEY,                          ID      SERIAL          PRIMARY KEY,
286                          hostID  INTEGER         NOT NULL references hosts(id),                          hostID  INTEGER         NOT NULL references hosts(id),
287                          name    VARCHAR(30)     NOT NULL,                          name    VARCHAR(30)     NOT NULL,
288                          share   VARCHAR(200)    NOT NULL,                          share   VARCHAR(200)    NOT NULL
                         localpath VARCHAR(200)        
289                  );                              );            
         });  
290    
         $dbh->do(qq{  
291                  create table dvds (                  create table dvds (
292                          ID      SERIAL          PRIMARY KEY,                          ID      SERIAL          PRIMARY KEY,
293                          num     INTEGER         NOT NULL,                          num     INTEGER         NOT NULL,
294                          name    VARCHAR(255)    NOT NULL,                          name    VARCHAR(255)    NOT NULL,
295                          mjesto  VARCHAR(255)                          mjesto  VARCHAR(255)
296                  );                  );
297          });  
           
         $dbh->do(qq{  
298                  create table backups (                  create table backups (
299                            id      serial,
300                          hostID  INTEGER         NOT NULL references hosts(id),                          hostID  INTEGER         NOT NULL references hosts(id),
301                          num     INTEGER         NOT NULL,                          num     INTEGER         NOT NULL,
302                          date    integer         NOT NULL,                          date    integer         NOT NULL,
303                          type    CHAR(4)         not null,                          type    CHAR(4)         not null,
304                          shareID integer         not null references shares(id),                          shareID integer         not null references shares(id),
305                          size    bigint          not null,                          size    bigint          not null,
306                          PRIMARY KEY(hostID, num, shareID)                          inc_size bigint         not null default -1,
307                            inc_deleted boolean     default false,
308                            parts   integer         not null default 1,
309                            PRIMARY KEY(id)
310                  );                              );            
         });  
   
         #do_index('backups_hostid,num_unique');  
   
311    
         $dbh->do(qq{      
312                  create table files (                  create table files (
313                          ID      SERIAL          PRIMARY KEY,                            ID              SERIAL,
314                          shareID INTEGER         NOT NULL references shares(id),                          shareID         INTEGER NOT NULL references shares(id),
315                          backupNum  INTEGER      NOT NULL,                          backupNum       INTEGER NOT NULL,
316                          name       VARCHAR(255) NOT NULL,                          name            VARCHAR(255) NOT NULL,
317                          path       VARCHAR(255) NOT NULL,                          path            VARCHAR(255) NOT NULL,
318                          date       integer      NOT NULL,                          date            integer NOT NULL,
319                          type       INTEGER      NOT NULL,                          type            INTEGER NOT NULL,
320                          size       INTEGER      NOT NULL                          size            bigint  NOT NULL,
321                            primary key(id)
322                  );                  );
         });  
323    
324                    create table archive (
325          $dbh->do( qq{                          id              serial,
                 create table archive  
                 (  
                         id                      int not null,  
326                          dvd_nr          int not null,                          dvd_nr          int not null,
327                            total_size      bigint default -1,
328                          note            text,                          note            text,
329                          username        varchar(20) not null,                          username        varchar(20) not null,
330                          date            timestamp,                          date            timestamp default now(),
331                          primary key(id)                          primary key(id)
332                  );                        );      
         }  
         );  
333    
334          $dbh->do( qq{                  create table archive_backup (
335                  create table archive_backup                          archive_id      int not null references archive(id) on delete cascade,
336                  (                          backup_id       int not null references backups(id),
                         archive_id      int not null,  
                         backup_id       int not null,  
                         status          text,  
337                          primary key(archive_id, backup_id)                          primary key(archive_id, backup_id)
338                  );                  );
         });  
339    
340          $dbh->do( qq{                  create table archive_burned (
341                  create table workflows(                          archive_id      int references archive(id),
342                          id                      int not null,                          date            timestamp default now(),
343                          step_id         int not null,                          part            int not null default 1,
344                          start           timestamp,                          copy            int not null default 1,
345                          stop            timestamp,                          iso_size bigint default -1
                         username        varchar(20),  
                         archive_id      int not null,  
                         running         boolean default true,  
                         primary key(id)  
346                  );                  );
         });  
   
         $dbh->do( qq{  
                 create table workflow_step  
                 (  
                         step_id         int not null,  
                         code            text,  
                         next_step       int,  
                         stop            boolean default false,  
                         primary key(step_id)  
                 );  
         });  
   
         $dbh->do( qq{  
                         alter table workflow_step  
                                 add constraint fk_workflow_next_step  
                                 foreign key(next_step)  
                                 references workflow_step(step_id);  
         });  
   
         $dbh->do( qq{  
                 alter table workflows  
                         add constraint fk_workflows_step_id  
                         foreign key(step_id)  
                         references workflow_step(step_id);  
         });  
           
         $dbh->do( qq{  
                 alter table workflows  
                         add constraint fk_workflows_archive_id  
                         foreign key(archive_id)  
                         references archive(id);  
         });  
347    
348          $dbh->do( qq{                  create table backup_parts (
349                  create table workflow_log                          id serial,
350                  (                          backup_id int references backups(id),
351                          workflow_id             int not null,                          part_nr int not null check (part_nr > 0),
352                          step_id                 int not null,                          tar_size bigint not null check (tar_size > 0),
353                          date                    timestamp not null,                          size bigint not null check (size > 0),
354                          status                  text,                          md5 text not null,
355                          primary key(workflow_id, step_id)                          items int not null check (items > 0),
356                            date timestamp default now(),
357                            primary key(id)
358                  );                  );
359          });          });
360    
361          $dbh->do( qq{          print "creating indexes: ";
                 alter table workflow_log  
                         add constraint fk_workflow_log_workflow_id  
                         foreign key (workflow_id)  
                         references workflows(id);  
                 });  
           
         $dbh->do( qq{  
                 alter table workflow_log  
                         add constraint fk_workflow_log_step_id  
                         foreign key (step_id)  
                         references      workflow_step(step_id);  
                 });  
   
         print "creating indexes:";  
362    
363          foreach my $index (qw(          foreach my $index (qw(
364                  hosts_name                  hosts:name
365                  backups_hostID                  backups:hostID
366                  backups_num                  backups:num
367                  shares_hostID                  backups:shareID
368                  shares_name                  shares:hostID
369                  files_shareID                  shares:name
370                  files_path                  files:shareID
371                  files_name                  files:path
372                  files_date                  files:name
373                  files_size                  files:date
374                    files:size
375                    archive:dvd_nr
376                    archive_burned:archive_id
377                    backup_parts:backup_id,part_nr
378          )) {          )) {
                 print " $index";  
379                  do_index($index);                  do_index($index);
380          }          }
381    
382            print " creating sequence: ";
383            foreach my $seq (qw/dvd_nr/) {
384                    print "$seq ";
385                    $dbh->do( qq{ CREATE SEQUENCE $seq } );
386            }
387    
388    
389          print "...\n";          print "...\n";
390    
391          $dbh->commit;          $dbh->commit;
# Line 487  WHERE hostID=? AND num=? AND shareid=? Line 429  WHERE hostID=? AND num=? AND shareid=?
429    
430  $sth->{insert_backups} = $dbh->prepare(qq{  $sth->{insert_backups} = $dbh->prepare(qq{
431  INSERT INTO backups (hostID, num, date, type, shareid, size)  INSERT INTO backups (hostID, num, date, type, shareid, size)
432  VALUES (?,?,?,?,?,?)  VALUES (?,?,?,?,?,-1)
433    });
434    
435    $sth->{update_backups_size} = $dbh->prepare(qq{
436    UPDATE backups SET size = ?
437    WHERE hostID = ? and num = ? and date = ? and type =? and shareid = ?
438  });  });
439    
440  $sth->{insert_files} = $dbh->prepare(qq{  $sth->{insert_files} = $dbh->prepare(qq{
# Line 496  INSERT INTO files Line 443  INSERT INTO files
443          VALUES (?,?,?,?,?,?,?)          VALUES (?,?,?,?,?,?,?)
444  });  });
445    
446  foreach my $host_key (keys %{$hosts}) {  my @hosts = keys %{$hosts};
447    my $host_nr = 0;
448    
449    foreach my $host_key (@hosts) {
450    
451          my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key";          my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key";
452    
# Line 511  foreach my $host_key (keys %{$hosts}) { Line 461  foreach my $host_key (keys %{$hosts}) {
461                  $hostID = $dbh->last_insert_id(undef,undef,'hosts',undef);                  $hostID = $dbh->last_insert_id(undef,undef,'hosts',undef);
462          }          }
463    
464          print "host ".$hosts->{$host_key}->{'host'}.": ";          $host_nr++;
465            print "host ", $hosts->{$host_key}->{'host'}, " [",
466                    $host_nr, "/", ($#hosts + 1), "]: ";
467    
468          # get backups for a host          # get backups for a host
469          my @backups = $bpc->BackupInfoRead($hostname);          my @backups = $bpc->BackupInfoRead($hostname);
# Line 553  foreach my $host_key (keys %{$hosts}) { Line 505  foreach my $host_key (keys %{$hosts}) {
505                          # dump some log                          # dump some log
506                          print curr_time," ", $share;                          print curr_time," ", $share;
507    
                         my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID);  
   
508                          $sth->{insert_backups}->execute(                          $sth->{insert_backups}->execute(
509                                  $hostID,                                  $hostID,
510                                  $backupNum,                                  $backupNum,
511                                  $backup->{'endTime'},                                  $backup->{'endTime'},
512                                  substr($backup->{'type'},0,4),                                  substr($backup->{'type'},0,4),
513                                  $shareID,                                  $shareID,
                                 $size,  
514                          );                          );
515    
516                          print " commit";                          my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID);
517                          $dbh->commit();  
518                            eval {
519                                    $sth->{update_backups_size}->execute(
520                                            $size,
521                                            $hostID,
522                                            $backupNum,
523                                            $backup->{'endTime'},
524                                            substr($backup->{'type'},0,4),
525                                            $shareID,
526                                    );
527                                    print " commit";
528                                    $dbh->commit();
529                            };
530                            if ($@) {
531                                    print " rollback";
532                                    $dbh->rollback();
533                            }
534    
535                          my $dur = (time() - $t) || 1;                          my $dur = (time() - $t) || 1;
536                          printf(" %d/%d files %d/%d dirs %0.2f MB [%.2f/s dur: %s]\n",                          printf(" %d/%d files %d/%d dirs %0.2f MB [%.2f/s dur: %s]\n",
# Line 604  sub getShareID() { Line 569  sub getShareID() {
569    
570          $sth->{insert_share} ||= $dbh->prepare(qq{          $sth->{insert_share} ||= $dbh->prepare(qq{
571                  INSERT INTO shares                  INSERT INTO shares
572                          (hostID,name,share,localpath)                          (hostID,name,share)
573                  VALUES (?,?,?,?)                  VALUES (?,?,?)
574          });          });
575    
576          my $drop_down = $hostname . '/' . $share;          my $drop_down = $hostname . '/' . $share;
577          $drop_down =~ s#//+#/#g;          $drop_down =~ s#//+#/#g;
578    
579          $sth->{insert_share}->execute($hostID,$share, $drop_down ,undef);          $sth->{insert_share}->execute($hostID,$share, $drop_down);
580          return $dbh->last_insert_id(undef,undef,'shares',undef);          return $dbh->last_insert_id(undef,undef,'shares',undef);
581  }  }
582    
# Line 628  sub found_in_db { Line 593  sub found_in_db {
593                  SELECT 1 FROM files                  SELECT 1 FROM files
594                  WHERE shareID = ? and                  WHERE shareID = ? and
595                          path = ? and                          path = ? and
596                          date = ? and                          size = ? and
597                          size = ?                          ( date = ? or date = ? or date = ? )
598                  LIMIT 1                  LIMIT 1
599          });          });
600    
601          my @param = ($shareID,$path,$date,$size);          my @param = ($shareID,$path,$size,$date, $date-$dst_offset, $date+$dst_offset);
602          $sth->{file_in_db}->execute(@param);          $sth->{file_in_db}->execute(@param);
603          my $rows = $sth->{file_in_db}->rows;          my $rows = $sth->{file_in_db}->rows;
604          print STDERR "## found_in_db($shareID,$path,$date,$size) ",( $rows ? '+' : '-' ), join(" ",@param), "\n" if ($debug >= 3);          print STDERR "## found_in_db($shareID,$path,$date,$size) ",( $rows ? '+' : '-' ), join(" ",@param), "\n" if ($debug >= 3);
# Line 683  sub recurseDir($$$$$$$$) { Line 648  sub recurseDir($$$$$$$$) {
648                                  $filesInBackup->{$path_key}->{'size'}                                  $filesInBackup->{$path_key}->{'size'}
649                          ));                          ));
650    
651                            my $key_dst_prev = join(" ", (
652                                    $shareID,
653                                    $dir,
654                                    $path_key,
655                                    $filesInBackup->{$path_key}->{'mtime'} - $dst_offset,
656                                    $filesInBackup->{$path_key}->{'size'}
657                            ));
658    
659                            my $key_dst_next = join(" ", (
660                                    $shareID,
661                                    $dir,
662                                    $path_key,
663                                    $filesInBackup->{$path_key}->{'mtime'} + $dst_offset,
664                                    $filesInBackup->{$path_key}->{'size'}
665                            ));
666    
667                          my $found;                          my $found;
668                          if (! defined($beenThere->{$key}) && ! ($found = found_in_db($key, @data)) ) {                          if (
669                                    ! defined($beenThere->{$key}) &&
670                                    ! defined($beenThere->{$key_dst_prev}) &&
671                                    ! defined($beenThere->{$key_dst_next}) &&
672                                    ! ($found = found_in_db($key, @data))
673                            ) {
674                                  print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2);                                  print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2);
675    
676                                  if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {                                  if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {

Legend:
Removed from v.136  
changed lines
  Added in v.306

  ViewVC Help
Powered by ViewVC 1.1.26