blob: 93312b862e3b68413db752e1392b671622195835 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package App::BorgRestore::Settings;
use v5.10;
use strict;
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 = (
{regex => "^/", replacement => ""},
);
my @configfiles = (
sprintf("%s/borg-restore.cfg", $ENV{XDG_CONFIG_HOME} // $ENV{HOME}."/.config"),
"/etc/borg-restore.cfg",
);
for my $configfile (@configfiles) {
$configfile = App::BorgRestore::Helper::untaint($configfile, qr/.*/);
if (-e $configfile) {
unless (my $return = do $configfile) {
die "couldn't parse $configfile: $@" if $@;
die "couldn't do $configfile: $!" unless defined $return;
die "couldn't run $configfile" unless $return;
}
}
}
$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__
|