--- trunk/bin/BackupPC_burnArchiveCLI 2006/03/01 13:04:03 337 +++ trunk/bin/BackupPC_burnArchiveCLI 2006/03/01 13:24:36 338 @@ -11,6 +11,7 @@ use Term::Menus; use File::Which; use File::Path; +use Filesys::Df; use Data::Dumper; @@ -193,23 +194,29 @@ $sth->execute(); +sub fmt_mb($) { + my $s = shift; + die "missing size" unless defined($s); + $s /= (1024*1024); + return sprintf("%.2f Mb", $s); +} + sub fmt_archive($) { my $row = shift || die; $row->{'date'} =~ s/\.\d+$//; $row->{'copies'} =~ s/^\s*0+\s*$/no/; - $row->{'total_size'} /= (1024*1024); my $copies = 'copies'; $copies = 'copy' if ($row->{'copies'} == 1); return - sprintf("%d by %s on %s, %s %s [%.2f Mb]", + sprintf("%d by %s on %s, %s %s [%s]", $row->{'dvd_nr'}, $row->{'username'}, $row->{'date'}, $row->{'copies'}, $copies, - $row->{'total_size'}, + fmt_mb($row->{'total_size'}), ); } @@ -382,6 +389,8 @@ $v = {}; } $v->{size} += $row->{part_size}; + $v_size += $row->{part_size}; + # this part my $p = { filename => BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}), @@ -393,7 +402,15 @@ } push @volumes, $v if ($v); - #warn "# volumes: ",Dumper(\@volumes),"\n"; + #warn "# volumes: ",Dumper(\@volumes)," total size: ", fmt_mb($v_size), "\n"; + + # check available disk space + + my $df = df($iso_dir); + if ($df < $v_size) { + warn "ABORTED: not enough disk space to create ISO ! [need ", fmt_mb($v_size), " have ", fmt_mb( df($iso_dir) ), "]\n"; + next; + } my $volumes = $#volumes + 1; my $volume_nr = 1; @@ -412,7 +429,7 @@ $disk_name .= ' ' . $volume_nr . '/' . $volumes; } - print "Processing DVD #$dvd_nr, volume $volume_nr/$volumes\n"; + print "Processing DVD #$dvd_nr, volume $volume_nr/$volumes [", fmt_mb($v->{size}), "]\n"; my $iso_file = my $xml_file = my $stage = "${iso_dir}/${dvd_nr}";