diff options
Diffstat (limited to 'lib/App/BorgRestore/Settings.pm')
-rw-r--r-- | lib/App/BorgRestore/Settings.pm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/App/BorgRestore/Settings.pm b/lib/App/BorgRestore/Settings.pm index 7416c54..93312b8 100644 --- a/lib/App/BorgRestore/Settings.pm +++ b/lib/App/BorgRestore/Settings.pm @@ -5,6 +5,8 @@ use warnings; use App::BorgRestore::Helper; +use File::Path qw(mkpath); + our $borg_repo = ""; our $cache_path_base = sprintf("%s/borg-restore.pl", $ENV{XDG_CACHE_HOME} // $ENV{HOME}."/.cache"); our @backup_prefixes = ( @@ -28,6 +30,19 @@ for my $configfile (@configfiles) { } $cache_path_base = App::BorgRestore::Helper::untaint($cache_path_base, qr/.*/); +# ensure the cache directory exists +mkpath(get_cache_dir(), {mode => oct(700)}); + +sub get_cache_dir { + return "$cache_path_base/v2"; +} + +sub get_cache_path { + my $item = shift; + return get_cache_dir()."/$item"; +} + + 1; __END__ |