--- trunk/lib/BackupPC/SearchLib.pm 2005/12/12 20:59:57 258 +++ trunk/lib/BackupPC/SearchLib.pm 2005/12/12 20:59:58 259 @@ -420,6 +420,36 @@ ); } +sub getVolumes($) { + my $id = shift; + + my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize"; + + my $sth = $dbh->prepare(qq{ + select + size + from backup_parts + where backup_id = ? + order by part_nr asc + }); + + $sth->execute($id); + + my $cumulative_size = 0; + my $volumes = 1; + + while(my ($size) = $sth->fetchrow_array) { + if ($cumulative_size + $size > $max_archive_size) { + $volumes++; + $cumulative_size = $size; + } else { + $cumulative_size += $size; + } + } + + return ($volumes,$cumulative_size); +} + sub getBackupsNotBurned($) { my $param = shift; @@ -468,14 +498,21 @@ while ( my $row = $sth->fetchrow_hashref() ) { $row->{'age'} = sprintf("%0.1f", ( $row->{'age'} / 86400 ) ); #$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); - $row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024); - # do some cluster calculation (approximate) and convert to kB - $row->{'inc_size'} = int(($row->{'inc_size'} + 1023 ) / ( 2 * 1024 ) * 2); + my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize"; + if ($row->{size} > $max_archive_size) { + ($row->{volumes}, $row->{inc_size_calc}) = getVolumes($row->{id}); + } + + $row->{size} = sprintf("%0.2f", $row->{size} / 1024 / 1024); + + # do some cluster calculation (approximate) + $row->{inc_size} = int(($row->{inc_size} + 1023 ) / ( 2 * 1024 ) * 2); + $row->{inc_size_calc} ||= $row->{inc_size}; push @ret, $row; } - return @ret; + return @ret; } sub displayBackupsGrid($) { @@ -591,7 +628,7 @@ background-color: transparent; } -#parts { +#volumes { padding: 0.4em; display: none; width: 100%; @@ -675,7 +712,9 @@ function update_sum(suma, suma_disp) { if (! suma_disp) suma_disp = suma; - element_id('forma').elements['totalsize'].value = suma_disp; + suma_disp = Math.floor(suma_disp / 1024); + element_id('forma').elements['totalsize_kb'].value = suma_disp; + element_id('forma').elements['totalsize'].value = suma; pbar_set(suma, media_size); debug('total size: ' + suma); } @@ -691,15 +730,18 @@ suma -= size; } - var parts = parseInt( element_id("prt" + e.name.substr(3)).value); - if (suma > max_file_size && suma == size && parts > 1) { - element_id("parts").innerHTML = "This will take "+parts+" mediums!"; - element_id("parts").style.display = 'block'; - update_sum(media_size, suma); - suma = media_size; - return suma; - } else { - element_id("parts").style.display = 'none'; + var volumes = parseInt( element_id("prt" + e.name.substr(3)).value); + if (volumes > 1) { + if (e.checked) { + element_id("volumes").innerHTML = "This will take "+volumes+" mediums!"; + element_id("volumes").style.display = 'block'; + suma = size; + update_sum(suma); + return suma; + } else { + suma -= size; + element_id("volumes").style.display = 'none'; + } } if (suma < 0) suma = 0; @@ -791,7 +833,8 @@
-Size: kB + +Size: kB
 
@@ -800,7 +843,7 @@

-
 
+
 
Note: @@ -833,7 +876,7 @@ sort_header($param, 'Size/Mb', 'size', 'center') . sort_header($param, 'gzip size/Kb', 'incsize', 'center') . qq{ - + medias }; my @color = (' bgcolor="#e0e0e0"', ''); @@ -860,6 +903,8 @@ '; } + my $img_url = $Conf{CgiImageDirURL}; + $retHTML .= '' . '' . $backup->{'host'} . ':' . $backup->{'share'} . '' . @@ -869,8 +914,9 @@ '' . $backup->{'age'} . '' . '' . $backup->{'size'} . '' . '' . $backup->{'inc_size'} . - '' . - '' . + '' . + '' . + '' . ( qq{media} x $backup->{volumes} ) . '' . "\n"; }