/[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 25 by dpavlin, Wed Jul 13 09:57:41 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    #print STDERR "recurse($hostname,$backupNum,$share,$dir,$shareID)\n";
276    
277          my ($nr_files, $new_files, $nr_dirs, $new_dirs) = (0,0,0,0);          my ($nr_files, $new_files, $nr_dirs, $new_dirs) = (0,0,0,0);
278    
279          my $files = BackupPC::View->new($bpc, $hostname, $backups);                      { # scope
280          my $filesInBackup = $files->dirAttrib($backupNum, $share, $dir);                  my @stack;
281    
282          # first, add all the entries in current directory                  my $files = BackupPC::View->new($bpc, $hostname, $backups);            
283          foreach my $path_key (keys %{$filesInBackup}) {                  my $filesInBackup = $files->dirAttrib($backupNum, $share, $dir);
                 my @data = (  
                         $shareID,  
                         $backupNum,  
                         $path_key,  
                         $filesInBackup->{$path_key}->{'relPath'},  
                         $filesInBackup->{$path_key}->{'fullPath'},  
 #                       $filesInBackup->{$path_key}->{'sharePathM'},  
                         $filesInBackup->{$path_key}->{'mtime'},  
                         $filesInBackup->{$path_key}->{'type'},  
                         $filesInBackup->{$path_key}->{'size'}  
                 );  
   
                 my $key = join(" ", (  
                         $shareID,  
                         $dir,  
                         $path_key,  
                         $filesInBackup->{$path_key}->{'mtime'},  
                         $filesInBackup->{$path_key}->{'size'}  
                 ));  
284    
285                    # first, add all the entries in current directory
286                    foreach my $path_key (keys %{$filesInBackup}) {
287                            my @data = (
288                                    $shareID,
289                                    $backupNum,
290                                    $path_key,
291                                    $filesInBackup->{$path_key}->{'relPath'},
292                                    $filesInBackup->{$path_key}->{'fullPath'},
293            #                       $filesInBackup->{$path_key}->{'sharePathM'},
294                                    $filesInBackup->{$path_key}->{'mtime'},
295                                    $filesInBackup->{$path_key}->{'type'},
296                                    $filesInBackup->{$path_key}->{'size'}
297                            );
298    
299                            my $key = join(" ", (
300                                    $shareID,
301                                    $dir,
302                                    $path_key,
303                                    $filesInBackup->{$path_key}->{'mtime'},
304                                    $filesInBackup->{$path_key}->{'size'}
305                            ));
306    
307    
308                            if (! $beenThere->{$key} && ! found_in_db(@data)) {
309    ##print STDERR "# key: $key [", $beenThere->{$key},"]";
310                                    $sth->{'insert_files'}->execute(@data);
311                                    if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
312                                            $new_dirs++;
313    ##print STDERR " dir\n";
314                                    } else {
315                                            $new_files++;
316    ##print STDERR " file\n";
317                                    }
318                            }
319                            $beenThere->{$key}++;
320    
                 if (! $beenThere->{$key} && ! found_in_db(@data)) {  
                         $sth->{'insert_files'}->execute(@data);  
 #                       print STDERR "$key\n";  
321                          if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {                          if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
322                                  $new_dirs++;                                  $nr_dirs++;
323    
324                                    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});
329    #
330    #                               $nr_files += $f;
331    #                               $new_files += $nf;
332    #                               $nr_dirs += $d;
333    #                               $new_dirs += $nd;
334    
335                          } else {                          } else {
336                                  $new_files++;                                  $nr_files++;
337                          }                          }
338                  }                  }
                 $beenThere->{$key}++;  
   
                 if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {  
                         $nr_dirs++;  
339    
340                          my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $path_key, $shareID);  ##print STDERR "# STACK ",join(", ", @stack),"\n";
341    
342                    while ( my $dir = shift @stack ) {
343                            my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID);
344    #       print STDERR "## $dir f: $f nf: $nf d: $d nd: $nd\n";
345                          $nr_files += $f;                          $nr_files += $f;
346                          $new_files += $nf;                          $new_files += $nf;
347                          $nr_dirs += $d;                          $nr_dirs += $d;
348                          $new_dirs += $nd;                          $new_dirs += $nd;
   
                 } else {  
                         $nr_files++;  
349                  }                  }
350          }          }
351    

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

  ViewVC Help
Powered by ViewVC 1.1.26