summaryrefslogtreecommitdiffstats
path: root/lib/App/BorgRestore
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-04-10 23:16:18 +0200
committerFlorian Pritz <bluewind@xinu.at>2017-04-10 23:16:18 +0200
commit2c8e59e9c0df286c6e01672acfb1f83e0fb728f0 (patch)
tree47e77d40812ebc38e1b782c49ba85a126b071d69 /lib/App/BorgRestore
parentd1e9868a9d5e60da0788c04bb744e269dff62fa0 (diff)
downloadApp-BorgRestore-2c8e59e9c0df286c6e01672acfb1f83e0fb728f0.tar.gz
App-BorgRestore-2c8e59e9c0df286c6e01672acfb1f83e0fb728f0.tar.xz
Use Function::Parameters in Borg package
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/BorgRestore')
-rw-r--r--lib/App/BorgRestore/Borg.pm22
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/App/BorgRestore/Borg.pm b/lib/App/BorgRestore/Borg.pm
index 402dba3..c1774d7 100644
--- a/lib/App/BorgRestore/Borg.pm
+++ b/lib/App/BorgRestore/Borg.pm
@@ -3,13 +3,11 @@ use v5.10;
use warnings;
use strict;
+use Function::Parameters;
use IPC::Run qw(run start new_chunker);
use Log::Any qw($log);
-sub new {
- my $class = shift;
- my $borg_repo = shift;
-
+method new($class: $borg_repo) {
my $self = {};
bless $self, $class;
@@ -18,8 +16,7 @@ sub new {
return $self;
}
-sub borg_list {
- my $self = shift;
+method borg_list() {
my @archives;
$log->debug("Getting archive list");
@@ -34,21 +31,12 @@ sub borg_list {
return \@archives;
}
-sub restore {
- my $self = shift;
- my $components_to_strip = shift;
- my $archive_name = shift;
- my $path = shift;
-
+method restore($components_to_strip, $archive_name, $path) {
$log->debugf("Restoring '%s' from archive %s, stripping %d components of the path", $path, $archive_name, $components_to_strip);
system(qw(borg extract -v --strip-components), $components_to_strip, $self->{borg_repo}."::".$archive_name, $path);
}
-sub list_archive {
- my $self = shift;
- my $archive = shift;
- my $cb = shift;
-
+method list_archive($archive, $cb) {
$log->debugf("Fetching file list for archive %s", $archive);
open (my $fh, '-|', 'borg', qw/list --list-format/, '{isomtime} {path}{NEWLINE}', $self->{borg_repo}."::".$archive);
while (<$fh>) {