summaryrefslogtreecommitdiffstats
path: root/lib/App/BorgRestore/Settings.pm
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-03-13 11:38:27 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-03-13 11:38:27 +0100
commit00c779c39d99bc046998866de83370f3c75b56d3 (patch)
tree70ef11ff5318ffc4c3ec9a90c099c9922fbd2f39 /lib/App/BorgRestore/Settings.pm
parentfb15de83cf35d11f657ebb1ad3aa01b334651264 (diff)
downloadApp-BorgRestore-00c779c39d99bc046998866de83370f3c75b56d3.tar.gz
App-BorgRestore-00c779c39d99bc046998866de83370f3c75b56d3.tar.xz
Refactor db creation and cache dir creation
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/BorgRestore/Settings.pm')
-rw-r--r--lib/App/BorgRestore/Settings.pm15
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__