From 9f2d12b96a0cb093fe3d85b60a7c6151d957bc0c Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 3 Mar 2017 20:13:55 +0100 Subject: Pass sub to IPC::Run instead of using a typeglob Signed-off-by: Florian Pritz --- lib/App/BorgRestore.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/App/BorgRestore.pm') 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 () { + 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} (?....)-(?..)-(?..) (?..):(?..):(?..) (?.+)$/) { + if ($line =~ m/^.{4} (?....)-(?..)-(?..) (?..):(?..):(?..) (?.+)$/) { 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)); -- cgit v1.2.3-24-g4f1b