summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/App/BorgRestore/DB.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/App/BorgRestore/DB.pm b/lib/App/BorgRestore/DB.pm
index d4e61df..feebd4c 100644
--- a/lib/App/BorgRestore/DB.pm
+++ b/lib/App/BorgRestore/DB.pm
@@ -102,7 +102,14 @@ sub remove_archive {
$self->{dbh}->do('alter table `files_new` rename to `files`');
- my $st = $self->{dbh}->prepare('delete from `archives` where `archive_name` = ?;');
+ my $sql = 'delete from `files` where ';
+ $sql .= join(' is null and ', grep {$_ ne '`path`' } @columns_to_copy);
+ $sql .= " is null";
+
+ my $st = $self->{dbh}->prepare($sql);
+ my $rows = $st->execute();
+
+ $st = $self->{dbh}->prepare('delete from `archives` where `archive_name` = ?;');
$st->execute($archive);
}