summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-03-03 20:13:55 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-03-03 23:16:17 +0100
commit9f2d12b96a0cb093fe3d85b60a7c6151d957bc0c (patch)
tree32b184116dab2f6f5ee1472e42a7aeb5370ab8cf /lib
parentbc8bd4c00183228f675fda77e571d66671fcaca1 (diff)
downloadApp-BorgRestore-9f2d12b96a0cb093fe3d85b60a7c6151d957bc0c.tar.gz
App-BorgRestore-9f2d12b96a0cb093fe3d85b60a7c6151d957bc0c.tar.xz
Pass sub to IPC::Run instead of using a typeglob
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/App/BorgRestore.pm8
-rw-r--r--lib/App/BorgRestore/Borg.pm6
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm
index 400c2fd..904c6b8 100644
--- a/lib/App/BorgRestore.pm
+++ b/lib/App/BorgRestore.pm
@@ -314,17 +314,17 @@ sub handle_added_archives {
$self->debug(sprintf("Adding archive %s", $archive));
- my $proc = $self->{borg}->list_archive($archive, \*OUT);
- while (<OUT>) {
+ my $proc = $self->{borg}->list_archive($archive, sub {
+ my $line = shift;
# roll our own parsing of timestamps for speed since we will be parsing
# a huge number of lines here
# example timestamp: "Wed, 2016-01-27 10:31:59"
- if (m/^.{4} (?<year>....)-(?<month>..)-(?<day>..) (?<hour>..):(?<minute>..):(?<second>..) (?<path>.+)$/) {
+ if ($line =~ m/^.{4} (?<year>....)-(?<month>..)-(?<day>..) (?<hour>..):(?<minute>..):(?<second>..) (?<path>.+)$/) {
my $time = POSIX::mktime($+{second},$+{minute},$+{hour},$+{day},$+{month}-1,$+{year}-1900);
#$self->debug(sprintf("Adding path %s with time %s", $+{path}, $time));
$self->add_path_to_hash($lookuptable, $+{path}, $time);
}
- }
+ });
$proc->finish() or die "borg list returned $?";
$self->debug(sprintf("Finished parsing borg output after %.5fs. Adding to db", Time::HiRes::gettimeofday - $start));
diff --git a/lib/App/BorgRestore/Borg.pm b/lib/App/BorgRestore/Borg.pm
index ebedb7d..412269f 100644
--- a/lib/App/BorgRestore/Borg.pm
+++ b/lib/App/BorgRestore/Borg.pm
@@ -3,7 +3,7 @@ use v5.10;
use warnings;
use strict;
-use IPC::Run qw(run start);
+use IPC::Run qw(run start new_chunker);
sub new {
my $class = shift;
@@ -41,9 +41,9 @@ sub restore {
sub list_archive {
my $self = shift;
my $archive = shift;
- my $fh = shift;
+ my $cb = shift;
- return start [qw(borg list --list-format), '{isomtime} {path}{NEWLINE}', "::".$archive], ">pipe", $fh;
+ return start [qw(borg list --list-format), '{isomtime} {path}{NEWLINE}', "::".$archive], ">", new_chunker, $cb;
}
1;