make check_archive transactionally safe
[BackupPC.git] / bin / BackupPC_ASA_PostArchive_Update
index 93478c9..e3d022d 100755 (executable)
@@ -230,7 +230,6 @@ sub check_archive {
                });
 
                $sth_insert->execute($backup_id, $part_nr, $tar_size, $size, $md5, $items, $filename);
-               $dbh->commit;
        }
 
        print " [parts: ",join(", ", @tar_parts),"]" if $opt->debug;
@@ -322,7 +321,6 @@ sub check_archive {
                $part_nr,
                get_backup_id($host, $num),
        );
-       $dbh->commit;
 
        @tar_files = sort @tar_files;
        print "\n\t",($#tar_files + 1), " tar files";
@@ -366,6 +364,8 @@ sub check_archive {
        print " ",($same ? 'ok' : 'DIFFERENT'),
                ", dur: ",fmt_time(time() - $t), "\n";
 
+       $dbh->commit;
+
        return $same;
 }
 
@@ -446,8 +446,6 @@ while (my $row = $sth->fetchrow_hashref) {
 
        print ", dur: ",fmt_time(time() - $t), "\n";
 
-       $dbh->commit;
-
 }
 
 undef $sth;