From 89e65e8533efd78fc7d616dc9dc4c42083ba99df Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 27 Feb 2017 10:59:14 +0100 Subject: Remove empty lines from the db Signed-off-by: Florian Pritz --- lib/App/BorgRestore/DB.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/App') 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); } -- cgit v1.2.3-24-g4f1b