From 6b9c0d7719afdf85820e703e58b1358c95b6586e Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 21 Nov 2017 15:56:04 +0100 Subject: Enable --adhoc automatically when cache is empty Signed-off-by: Florian Pritz --- lib/App/BorgRestore.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index edc009c..d96b957 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -235,6 +235,19 @@ method get_all_archives() { return \@ret; } +=head3 cache_contains_data + + if ($app->cache_contains_data()) { ... } + +Returns 1 if the cache contains any archive data, 0 otherwise. + +=cut + +method cache_contains_data() { + my $existing_archives = $self->{db}->get_archive_names(); + return @{$existing_archives}+0 > 0 ? 1 : 0; +} + =head3 select_archive_timespec my $archive = $app->select_archive_timespec($archives, $timespec); -- cgit v1.2.3-24-g4f1b