diff options
-rw-r--r-- | lib/App/BorgRestore.pm | 6 | ||||
-rw-r--r-- | lib/App/BorgRestore/Settings.pm | 5 |
2 files changed, 11 insertions, 0 deletions
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<find_archives>. =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"; } |