diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/BorgRestore.pm | 2 | ||||
-rw-r--r-- | lib/App/BorgRestore/Borg.pm | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index 90b7d61..e039011 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -85,7 +85,7 @@ sub new { my $db_path = App::BorgRestore::Settings::get_db_path(); - $self->{borg} = $deps->{borg} // App::BorgRestore::Borg->new(); + $self->{borg} = $deps->{borg} // App::BorgRestore::Borg->new($App::BorgRestore::Settings::borg_repo); $self->{db} = $deps->{db} // App::BorgRestore::DB->new($db_path); return $self; diff --git a/lib/App/BorgRestore/Borg.pm b/lib/App/BorgRestore/Borg.pm index 8b4e953..38c12ae 100644 --- a/lib/App/BorgRestore/Borg.pm +++ b/lib/App/BorgRestore/Borg.pm @@ -7,10 +7,13 @@ use IPC::Run qw(run start new_chunker); sub new { my $class = shift; + my $borg_repo = shift; my $self = {}; bless $self, $class; + $self->{borg_repo} = $borg_repo; + return $self; } @@ -18,7 +21,7 @@ sub borg_list { my $self = shift; my @archives; - run [qw(borg list)], '>', \my $output or die "borg list returned $?"; + run [qw(borg list), $self->{borg_repo}], '>', \my $output or die "borg list returned $?"; for (split/^/, $output) { if (m/^([^\s]+)\s/) { @@ -35,7 +38,7 @@ sub restore { my $archive_name = shift; my $path = shift; - system(qw(borg extract -v --strip-components), $components_to_strip, "::".$archive_name, $path); + system(qw(borg extract -v --strip-components), $components_to_strip, $self->{borg_repo}."::".$archive_name, $path); } sub list_archive { @@ -43,7 +46,7 @@ sub list_archive { my $archive = shift; my $cb = shift; - open (my $fh, '-|', 'borg', qw/list --list-format/, '{isomtime} {path}{NEWLINE}', "::".$archive); + open (my $fh, '-|', 'borg', qw/list --list-format/, '{isomtime} {path}{NEWLINE}', $self->{borg_repo}."::".$archive); while (<$fh>) { $cb->($_); } |