my $total_size = 0;
my $selected = 0;
+ my $parts = 1;
+
foreach my $key(keys(%In)) {
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);
$selected++;
- }
- }
- # and now a little magic to check multi-volume increments
- my $parts = 1;
- if ($#selected_backup_ids == 0) {
- ($parts) = $dbh->selectrow_array("select parts from backups where id = ?", undef, $selected_backup_ids[0]);
+ 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)}});
- $cont .= "Selected backups size $total_size Kb exceed max archive size $Conf{MaxArchiveSize} Kb.";
+ $cont .= "Selected backups size " . sprintf("%1.2f", $total_size / 1024) ." Kb exceed max archive size " . sprintf("%1.2f", $Conf{MaxArchiveSize} / 1024) ." Kb.";
} elsif ($total_size == 0) {
$cont .= eval( q{ ${h2(Error)}});
$cont .= "No backups selected.";
# create new archive
my $sth = $dbh->prepare(q{
- INSERT INTO archive (
- id,
- dvd_nr,
- note,
- username,
- date,
- total_size
- ) VALUES (
- nextVal('archive_id_seq'),
- nextVal('dvd_nr'),
- ?,
- ?,
- NOW(),
- ?
- )
- });
+ INSERT INTO archive (
+ id,
+ dvd_nr,
+ note,
+ username,
+ date,
+ total_size
+ ) VALUES (
+ nextVal('archive_id_seq'),
+ nextVal('dvd_nr'),
+ ?,
+ ?,
+ NOW(),
+ ?
+ )
+ });
$sth->execute($In{'note'}, $User, $total_size);