small speedup and nicer output
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Mon, 22 Aug 2005 08:58:59 +0000 (08:58 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Mon, 22 Aug 2005 08:58:59 +0000 (08:58 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@67 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_updatedb

index 19f7760..bab727a 100755 (executable)
@@ -223,13 +223,15 @@ foreach my $host_key (keys %{$hosts}) {
                $hostID = $dbh->last_insert_id(undef,undef,'hosts',undef);
        }
 
-       print("host ".$hosts->{$host_key}->{'host'}.": ");
+       print "host ".$hosts->{$host_key}->{'host'}.": ";
  
        # get backups for a host
        my @backups = $bpc->BackupInfoRead($hostname);
-       print scalar @backups, " increments\n";
+       my $incs = scalar @backups;
+       print  "$incs increments\n";
 
        my $inc_nr = 0;
+       $beenThere = {};
 
        foreach my $backup (@backups) {
 
@@ -239,14 +241,14 @@ foreach my $host_key (keys %{$hosts}) {
                my $backupNum = $backup->{'num'};
                my @backupShares = ();
 
-               print $hosts->{$host_key}->{'host'},
-                       "\t#$backupNum\t", $backup->{type} || '?', " ",
-                       $backup->{nFilesNew} || '?', "/", $backup->{nFiles} || '?',
-                       " files (date: ",
+               printf("%-10s %2d/%-2d #%-2d %s %5s/%5s files (date: %s dur: %s)\n", 
+                       $hosts->{$host_key}->{'host'},
+                       $inc_nr, $incs, $backupNum, 
+                       $backup->{type} || '?',
+                       $backup->{nFilesNew} || '?', $backup->{nFiles} || '?',
                        strftime($t_fmt,localtime($backup->{startTime})),
-                       " dur: ",
-                       fmt_time($backup->{endTime} - $backup->{startTime}),
-                       ")\n";
+                       fmt_time($backup->{endTime} - $backup->{startTime})
+               );
 
                my $files = BackupPC::View->new($bpc, $hostname, \@backups, 1);
                foreach my $share ($files->shareList($backupNum)) {
@@ -336,12 +338,11 @@ sub found_in_db {
                SELECT 1 FROM files
                WHERE shareID = ? and
                        path = ? and 
-                       name = ? and
                        date = ? and
                        size = ?
        });
 
-       my @param = ($shareID,$path,$name,$date,$size);
+       my @param = ($shareID,$path,$date,$size);
        $sth->{file_in_db}->execute(@param);
        my $rows = $sth->{file_in_db}->rows;
        print STDERR "## found_in_db ",( $rows ? '+' : '-' ), join(" ",@param), "\n" if ($debug >= 3);