summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-10-21 13:15:03 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-10-21 13:15:03 +0000
commit905851a1beac15d6936b9f93fb701660fb676617 (patch)
tree5631bff85d6bb3b927b3da28c7dacdad8d8c3e7c /urpm
parentef2bddb00f49c56f7786ae587a56bc3cc9cd9ef0 (diff)
downloadurpmi-905851a1beac15d6936b9f93fb701660fb676617.tar
urpmi-905851a1beac15d6936b9f93fb701660fb676617.tar.gz
urpmi-905851a1beac15d6936b9f93fb701660fb676617.tar.bz2
urpmi-905851a1beac15d6936b9f93fb701660fb676617.tar.xz
urpmi-905851a1beac15d6936b9f93fb701660fb676617.zip
create _parse_aria2_output() out of sync_aria2()
Diffstat (limited to 'urpm')
-rw-r--r--urpm/download.pm15
1 files changed, 11 insertions, 4 deletions
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 {