summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-09-09 10:52:18 +0200
committerFlorian Pritz <bluewind@xinu.at>2018-09-09 15:45:11 +0200
commit3c55b139aa0371e7bace5ef9b76ff3c15fddca88 (patch)
tree7c92962b9ab9703ad20866d5a93372bd4a01a1a9
parentda0048ce63d3f9ffeddda765652acce635d71834 (diff)
downloadApp-BorgRestore-3c55b139aa0371e7bace5ef9b76ff3c15fddca88.tar.gz
App-BorgRestore-3c55b139aa0371e7bace5ef9b76ff3c15fddca88.tar.xz
Settings: Pull config file loading into function
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--lib/App/BorgRestore/Settings.pm31
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/App/BorgRestore/Settings.pm b/lib/App/BorgRestore/Settings.pm
index 8cbbf9c..31249c5 100644
--- a/lib/App/BorgRestore/Settings.pm
+++ b/lib/App/BorgRestore/Settings.pm
@@ -125,28 +125,33 @@ our @backup_prefixes = (
);
our $sqlite_cache_size = 102400;
our $prepare_data_in_memory = 1;
-my @configfiles;
-
-if (defined $ENV{XDG_CONFIG_HOME} or defined $ENV{HOME}) {
- push @configfiles, sprintf("%s/borg-restore.cfg", $ENV{XDG_CONFIG_HOME} // $ENV{HOME}."/.config");
-}
-push @configfiles, "/etc/borg-restore.cfg";
if (defined $ENV{XDG_CACHE_HOME} or defined $ENV{HOME}) {
$cache_path_base = sprintf("%s/borg-restore.pl", $ENV{XDG_CACHE_HOME} // $ENV{HOME} ."/.cache");
}
-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;
+fun load_config_files() {
+ my @configfiles;
+
+ if (defined $ENV{XDG_CONFIG_HOME} or defined $ENV{HOME}) {
+ push @configfiles, sprintf("%s/borg-restore.cfg", $ENV{XDG_CONFIG_HOME} // $ENV{HOME}."/.config");
+ }
+ push @configfiles, "/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;
+ }
}
}
}
+load_config_files();
+
if (not defined $cache_path_base) {
die "Error: \$cache_path_base is not defined. This is most likely because the\n"
."environment variables \$HOME and \$XDG_CACHE_HOME are not set. Consider setting\n"