correct calculation of free space
[BackupPC.git] / bin / BackupPC_burnArchiveCLI
index 18013c2..f8845d4 100755 (executable)
@@ -406,9 +406,10 @@ foreach my $copy_nr ( 1 .. $copies ) {
 
                # check available disk space
 
-               my $df = df($iso_dir);
+               my $df = df($iso_dir)->{bavail} || die "can't get free space on $iso_dir";
+               $df *= 1024;    # calulate space in bytes
                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";
+                       warn "ABORTED: not enough disk space to create ISO ! [need ", fmt_mb($v_size), " have ", fmt_mb( $df ), " on $iso_dir]\n";
                        next;
                }
 
@@ -528,7 +529,16 @@ foreach my $copy_nr ( 1 .. $copies ) {
                        $sth_archive_burned->execute($dvd_nr, $iso_size, $volume_nr, $copy_nr);
 
                        print "Media burn for $disk_name copy $copy_nr recorded\n";
-               
+
+                       if ($copy_nr >= $copies) {
+                               print STDERR "erasing temporary files, have $copy_nr copies (> $copies)\n";
+                               foreach my $f (( $xml_file, $iso_file )) {
+                                       print STDERR "\t$f ";
+                                       unlink $f || die "can't remove $f: $!";
+                                       print STDERR "removed\n";
+                               }
+                       }
+
                        $volume_nr++;
                }