From 12a21ee5bbde99ae5273f777aaf5e3c606b69729 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 4 Mar 2017 00:15:30 +0100 Subject: Borg::list_archive: Use open() instead of IPC::Run for performance Surprisingly the callback isn't actually that bad, but IPC::Run (probably new_chunker) adds quite some overhead. Since open supports everything we need, use that instead. Signed-off-by: Florian Pritz --- lib/App/BorgRestore/Borg.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/App/BorgRestore/Borg.pm') diff --git a/lib/App/BorgRestore/Borg.pm b/lib/App/BorgRestore/Borg.pm index 412269f..8b4e953 100644 --- a/lib/App/BorgRestore/Borg.pm +++ b/lib/App/BorgRestore/Borg.pm @@ -43,7 +43,14 @@ sub list_archive { my $archive = shift; my $cb = shift; - return start [qw(borg list --list-format), '{isomtime} {path}{NEWLINE}', "::".$archive], ">", new_chunker, $cb; + open (my $fh, '-|', 'borg', qw/list --list-format/, '{isomtime} {path}{NEWLINE}', "::".$archive); + while (<$fh>) { + $cb->($_); + } + + # this is slow + #return start [qw(borg list --list-format), '{isomtime} {path}{NEWLINE}', "::".$archive], ">", new_chunker, $cb; + #$proc->finish() or die "borg list returned $?"; } 1; -- cgit v1.2.3-24-g4f1b