From 905851a1beac15d6936b9f93fb701660fb676617 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 21 Oct 2008 13:15:03 +0000 Subject: create _parse_aria2_output() out of sync_aria2() --- urpm/download.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'urpm/download.pm') diff --git a/urpm/download.pm b/urpm/download.pm index 34e6c8bf..75b08274 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -683,6 +683,15 @@ sub sync_aria2 { local $ENV{LC_ALL} = 'C'; my $aria2_pid = open(my $aria2, "$aria2c_command |"); + _parse_aria2_output($options, $aria2, $aria2_pid, [ @urls_text ]); + + chdir $cwd; + close $aria2 or _error('aria2'); +} + +sub _parse_aria2_output { + my ($options, $aria2, $aria2_pid, $urls_text) = @_; + my ($buf, $_total, $file) = ('', undef, undef); local $/ = \1; #- read input by only one char, this is slow but very nice (and it works!). @@ -692,8 +701,8 @@ sub sync_aria2 { if ($_ eq "\r" || $_ eq "\n") { $options->{debug}("aria2c: $buf") if $options->{debug}; if ($options->{callback}) { - if (!defined($file) && @urls_text) { - $file = shift @urls_text; + if (!defined($file) && @$urls_text) { + $file = shift @$urls_text; propagate_sync_callback($options, 'start', $file); } if ($buf =~ m!^\[#\d*\s+\S+:([\d\.]+\w*).([\d\.]+\w*)\S([\d]+)\S+\s+\S+\s*([\d\.]+)\s\w*:([\d\.]+\w*/\w)\s\w*:(\d+\w*)\]$!) { @@ -719,8 +728,6 @@ sub sync_aria2 { $buf .= $_; } } - chdir $cwd; - close $aria2 or _error('aria2'); } sub start_ssh_master { -- cgit v1.2.1