/[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 27 by dpavlin, Fri Jul 29 17:31:14 2005 UTC revision 29 by dpavlin, Sun Jul 31 12:40:51 2005 UTC
# Line 192  foreach my $host_key (keys %{$hosts}) { Line 192  foreach my $host_key (keys %{$hosts}) {
192                  my ($broj) = $sth->{backups_broj}->fetchrow_array();                  my ($broj) = $sth->{backups_broj}->fetchrow_array();
193                  next if ($broj > 0);                  next if ($broj > 0);
194    
                 $sth->{insert_backups}->execute(  
                         $hostID,  
                         $backupNum,  
                         $backup->{'endTime'},  
                         $backup->{'type'}  
                 );  
                 $dbh->commit();  
   
195                  my $files = BackupPC::View->new($bpc, $hostname, \@backups);                  my $files = BackupPC::View->new($bpc, $hostname, \@backups);
196                  foreach my $share ($files->shareList($backupNum)) {                  foreach my $share ($files->shareList($backupNum)) {
197    
# Line 210  foreach my $host_key (keys %{$hosts}) { Line 202  foreach my $host_key (keys %{$hosts}) {
202                          print " $nf/$f files $nd/$d dirs\n";                          print " $nf/$f files $nd/$d dirs\n";
203                          $dbh->commit();                          $dbh->commit();
204                  }                  }
205    
206                    $sth->{insert_backups}->execute(
207                            $hostID,
208                            $backupNum,
209                            $backup->{'endTime'},
210                            $backup->{'type'}
211                    );
212                    $dbh->commit();
213    
214          }          }
215  }  }
216  undef $sth;  undef $sth;
# Line 271  sub recurseDir($$$$$$$$) { Line 272  sub recurseDir($$$$$$$$) {
272    
273          my ($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID) = @_;          my ($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID) = @_;
274    
275          my ($nr_files, $new_files, $nr_dirs, $new_dirs) = (0,0,0,0);  #print STDERR "recurse($hostname,$backupNum,$share,$dir,$shareID)\n";
276    
277          my @stack;          my ($nr_files, $new_files, $nr_dirs, $new_dirs) = (0,0,0,0);
278    
279          { # scope          { # scope
280                    my @stack;
281    
282                  my $files = BackupPC::View->new($bpc, $hostname, $backups);                              my $files = BackupPC::View->new($bpc, $hostname, $backups);            
283                  my $filesInBackup = $files->dirAttrib($backupNum, $share, $dir);                  my $filesInBackup = $files->dirAttrib($backupNum, $share, $dir);
284    
 print STDERR "$hostname: $share | $dir | $backupNum\n";  
   
285                  # first, add all the entries in current directory                  # first, add all the entries in current directory
286                  foreach my $path_key (keys %{$filesInBackup}) {                  foreach my $path_key (keys %{$filesInBackup}) {
287                          my @data = (                          my @data = (
# Line 306  print STDERR "$hostname: $share | $dir | Line 306  print STDERR "$hostname: $share | $dir |
306    
307    
308                          if (! $beenThere->{$key} && ! found_in_db(@data)) {                          if (! $beenThere->{$key} && ! found_in_db(@data)) {
309    ##print STDERR "# key: $key [", $beenThere->{$key},"]";
310                                  $sth->{'insert_files'}->execute(@data);                                  $sth->{'insert_files'}->execute(@data);
                                 print STDERR "$key\n";  
311                                  if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {                                  if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
312                                          $new_dirs++;                                          $new_dirs++;
313    ##print STDERR " dir\n";
314                                  } else {                                  } else {
315                                          $new_files++;                                          $new_files++;
316    ##print STDERR " file\n";
317                                  }                                  }
318                          }                          }
319                          $beenThere->{$key}++;                          $beenThere->{$key}++;
# Line 319  print STDERR "$hostname: $share | $dir | Line 321  print STDERR "$hostname: $share | $dir |
321                          if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {                          if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
322                                  $nr_dirs++;                                  $nr_dirs++;
323    
324                                  push @stack, [ $bpc, $hostname, $backups, $backupNum, $share, $path_key, $shareID ] unless ($beenThere->{$key});                                  my $full_path = $dir . '/' . $path_key;
325                                    push @stack, $full_path;
326    ##print STDERR "### store to stack: $full_path\n";
327    
328  #                               my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $path_key, $shareID) unless ($beenThere->{$key});  #                               my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $path_key, $shareID) unless ($beenThere->{$key});
329  #  #
330  #                               $nr_files += $f;  #                               $nr_files += $f;
# Line 332  print STDERR "$hostname: $share | $dir | Line 337  print STDERR "$hostname: $share | $dir |
337                          }                          }
338                  }                  }
339    
340          }  ##print STDERR "# STACK ",join(", ", @stack),"\n";
341    
342          foreach my $r (@stack) {                  while ( my $dir = shift @stack ) {
343                  my ($f,$nf,$d,$nd) = recurseDir(@{$r});                          my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID);
344                  $nr_files += $f;  #       print STDERR "## $dir f: $f nf: $nf d: $d nd: $nd\n";
345                  $new_files += $nf;                          $nr_files += $f;
346                  $nr_dirs += $d;                          $new_files += $nf;
347                  $new_dirs += $nd;                          $nr_dirs += $d;
348                            $new_dirs += $nd;
349                    }
350          }          }
351    
352          return ($nr_files, $new_files, $nr_dirs, $new_dirs);          return ($nr_files, $new_files, $nr_dirs, $new_dirs);

Legend:
Removed from v.27  
changed lines
  Added in v.29

  ViewVC Help
Powered by ViewVC 1.1.26