summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-02-27 10:59:14 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-02-27 10:59:14 +0100
commit89e65e8533efd78fc7d616dc9dc4c42083ba99df (patch)
tree30f1ef664e61dba87d4d7b7915ac9a2bf6950379 /lib
parent6ceae7a7870ddef792f863a546082ea28530c5cf (diff)
downloadApp-BorgRestore-89e65e8533efd78fc7d616dc9dc4c42083ba99df.tar.gz
App-BorgRestore-89e65e8533efd78fc7d616dc9dc4c42083ba99df.tar.xz
Remove empty lines from the db
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib')
-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);
}