From fd63fc156bcdf68e4a774409c92f55297415bb88 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 26 Nov 2017 00:11:51 +0100 Subject: Remove old cache Signed-off-by: Florian Pritz --- lib/App/BorgRestore.pm | 6 ++++++ lib/App/BorgRestore/Settings.pm | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'lib/App') diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index 68f12ff..99f482e 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -505,6 +505,12 @@ Updates the database used by e.g. C. =cut method update_cache() { + my $v2_basedir = App::BorgRestore::Settings::get_cache_base_dir_path("v2"); + if (-e $v2_basedir) { + $log->info("Removing old v2 cache directory: $v2_basedir"); + path($v2_basedir)->remove_tree; + } + $log->debug("Updating cache if required"); my $borg_archives = $self->{borg}->borg_list(); diff --git a/lib/App/BorgRestore/Settings.pm b/lib/App/BorgRestore/Settings.pm index d7cea4b..a581dab 100644 --- a/lib/App/BorgRestore/Settings.pm +++ b/lib/App/BorgRestore/Settings.pm @@ -123,6 +123,11 @@ for my $configfile (@configfiles) { } $cache_path_base = App::BorgRestore::Helper::untaint($cache_path_base, qr/.*/); +sub get_cache_base_dir_path { + my $path = shift; + return "$cache_path_base/$path"; +} + sub get_cache_dir { return "$cache_path_base/v3"; } -- cgit v1.2.3-24-g4f1b