From 2c8e59e9c0df286c6e01672acfb1f83e0fb728f0 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 10 Apr 2017 23:16:18 +0200 Subject: Use Function::Parameters in Borg package Signed-off-by: Florian Pritz --- lib/App/BorgRestore/Borg.pm | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'lib/App/BorgRestore') 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>) { -- cgit v1.2.3-24-g4f1b