From 00c779c39d99bc046998866de83370f3c75b56d3 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 13 Mar 2017 11:38:27 +0100 Subject: Refactor db creation and cache dir creation Signed-off-by: Florian Pritz --- lib/App/BorgRestore/Settings.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/App/BorgRestore/Settings.pm') 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__ -- cgit v1.2.3-24-g4f1b