diff options
author | Florian Pritz <bluewind@xinu.at> | 2017-11-26 00:11:51 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2017-11-26 00:11:51 +0100 |
commit | fd63fc156bcdf68e4a774409c92f55297415bb88 (patch) | |
tree | defe20df04b83f67905b55060660768ba333e9bd | |
parent | de186e51e282f28feb4d438a962e27cf41c34b31 (diff) | |
download | App-BorgRestore-fd63fc156bcdf68e4a774409c92f55297415bb88.tar.gz App-BorgRestore-fd63fc156bcdf68e4a774409c92f55297415bb88.tar.xz |
Remove old cache
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-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"; } |