- fixed problem with determining file size of tgz on disk: if there is no file, it...
authoriklaric <iklaric@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Wed, 9 May 2007 07:07:02 +0000 (07:07 +0000)
committeriklaric <iklaric@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Wed, 9 May 2007 07:07:02 +0000 (07:07 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@380 8392b6e1-25fa-0310-8288-cc32f8e212ea

lib/BackupPC/CGI/BurnMedia.pm
lib/BackupPC/SearchLib.pm

index 0bd4bff..e6beac2 100644 (file)
@@ -41,19 +41,22 @@ EOF
                my $selected = 0;
 
                my $parts = 1;
-
                foreach my $key(keys(%In)) {
+                       print LOG "doing $key...";
                        if ($key =~ m/^fcb([0-9]+)_([0-9]+)_([0-9]+)$/gi) {
+
                                my ($host_id, $backup_num, $backup_id) = ($1,$2,$3);
                                push @selected_backup_ids, $backup_id;
-                               $total_size += BackupPC::SearchLib::getGzipSize($host_id, $backup_num);
+                               my $currSize = BackupPC::SearchLib::getGzipSize($host_id, $backup_num);
+                               if ($currSize > 0) {
+                                       $total_size += currSize;
+                               }
                                $selected++;
 
                                my ($this_part) = $dbh->selectrow_array("select parts from backups where id = ?", undef, $backup_id);
                                $this_part--;
                                $parts += $this_part;
-                       }
-               }
+                       }               }
 
                if ($total_size > ($Conf{MaxArchiveSize} * $parts)) {
                        $cont .= eval( q{ ${h2(Error)}});
index 792d5b9..0355311 100644 (file)
@@ -20,10 +20,7 @@ my $db_user = $Conf{SearchUser} || '';
 my $hest_node_url = $Conf{HyperEstraierIndex};
 
 my $dbh;
-my $Dir = $Conf{InstallDir}."/data/log";
-open(LOG, ">>", "$Dir/LOG")
-select(LOG);
-$|=1;
+
 
 
 sub get_dbh {
@@ -383,21 +380,18 @@ sub get_tgz_size_by_name($) {
        my $tgz = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.$name;
        my $size = -1;
 
+       my $Dir = $Conf{InstallDir}."/data/log";
+       $|=1;
        if (-f "${tgz}.tar.gz") {
-               print "stating ${tgz}.tar.gz...";
                $size = (stat("${tgz}.tar.gz"))[7];
-               print "size: $size\n";
        } elsif (-d $tgz) {
-               print "$tgz is dir, stating files in it...\n";
                opendir(my $dir, $tgz) || die "can't opendir $tgz: $!";
                my @parts = grep { !/^\./ && !/md5/ && -f "$tgz/$_" } readdir($dir);
                $size = 0;
                foreach my $part (@parts) {
                        my $currSize =  (stat("$tgz/$part"))[7]; 
                        $size += (stat("$tgz/$part"))[7] || die "can't stat $tgz/$part: $!";
-                       print "\t$tgz/$part: $currSize\n";
                }
-               print "\ttotal $size\n";
 
                closedir $dir;
        } else {