summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-04-02 13:18:52 +0200
committerFlorian Pritz <bluewind@xinu.at>2017-04-02 13:42:15 +0200
commit6267cc40f59bd581a20354099b8838c40280f035 (patch)
treed8865be8ca3f0aeca7f5c064dbd3efa3bcd14305
parent9cdd04d549b15eb509042b470d5b63f4a9d3fb15 (diff)
downloadApp-BorgRestore-6267cc40f59bd581a20354099b8838c40280f035.tar.gz
App-BorgRestore-6267cc40f59bd581a20354099b8838c40280f035.tar.xz
Refactor update_cache()
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--lib/App/BorgRestore.pm27
1 files changed, 9 insertions, 18 deletions
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm
index 238fa50..e8a3edb 100644
--- a/lib/App/BorgRestore.pm
+++ b/lib/App/BorgRestore.pm
@@ -338,21 +338,6 @@ sub _handle_added_archives {
}
}
-sub build_archive_cache {
- my $self = shift;
- my $borg_archives = $self->{borg}->borg_list();
- my $db_path = App::BorgRestore::Settings::get_cache_path('archives.db');
-
- my $archives = $self->{db}->get_archive_names();
-
- $log->debugf("Found %d archives in db", scalar(@$archives));
-
- $self->_handle_removed_archives($borg_archives);
- $self->_handle_added_archives($borg_archives);
-
- $log->debugf("DB contains information for %d archives in %d rows", scalar(@{$self->{db}->get_archive_names()}), $self->{db}->get_archive_row_count());
-}
-
sub _save_node {
my $self = shift;
my $archive_id = shift;
@@ -373,9 +358,15 @@ sub _save_node {
sub update_cache {
my $self = shift;
- $log->debug("Checking if cache is complete");
- $self->build_archive_cache();
- $log->debug("Cache complete");
+
+ $log->debug("Updating cache if required");
+
+ my $borg_archives = $self->{borg}->borg_list();
+
+ $self->_handle_removed_archives($borg_archives);
+ $self->_handle_added_archives($borg_archives);
+
+ $log->debugf("DB contains information for %d archives in %d rows", scalar(@{$self->{db}->get_archive_names()}), $self->{db}->get_archive_row_count());
}