diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-09-06 18:19:07 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-09-06 18:19:07 +0200 |
commit | b8d19a541782812a4cd02a408344760d83b7b4e0 (patch) | |
tree | 35a76837e3cbb16067438d8d94d2399ee6914224 /lib/App/BorgRestore/DB.pm | |
parent | 892db03a49333daf7d808395a0a25e81ec2a76ab (diff) | |
download | App-BorgRestore-b8d19a541782812a4cd02a408344760d83b7b4e0.tar.gz App-BorgRestore-b8d19a541782812a4cd02a408344760d83b7b4e0.tar.xz |
Add direct-to-db adding of paths instead of memory only
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/BorgRestore/DB.pm')
-rw-r--r-- | lib/App/BorgRestore/DB.pm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/App/BorgRestore/DB.pm b/lib/App/BorgRestore/DB.pm index 0c6c057..6af14af 100644 --- a/lib/App/BorgRestore/DB.pm +++ b/lib/App/BorgRestore/DB.pm @@ -156,16 +156,26 @@ method get_archives_for_path($path) { return \@ret; } - -method add_path($archive_id, $path, $time) { +method _insert_path($archive_id, $path, $time) { my $st = $self->{dbh}->prepare_cached('insert or ignore into `files` (`path`, `'.$archive_id.'`) values(?, ?)'); $st->execute($path, $time); +} + +method add_path($archive_id, $path, $time) { + $self->_insert_path($archive_id, $path, $time); - $st = $self->{dbh}->prepare_cached('update files set `'.$archive_id.'` = ? where `path` = ?'); + my $st = $self->{dbh}->prepare_cached('update files set `'.$archive_id.'` = ? where `path` = ?'); $st->execute($time, $path); } +method update_path_if_greater($archive_id, $path, $time) { + $self->_insert_path($archive_id, $path, $time); + + my $st = $self->{dbh}->prepare_cached('update files set `'.$archive_id.'` = ? where `path` = ? and `'.$archive_id.'` < ?'); + $st->execute($time, $path, $time); +} + method begin_work() { $self->{dbh}->begin_work(); } |