From 9c692705a7df1d92e5e0f3c4aa2453bf0bdab170 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 30 Jul 2009 13:16:04 +0000 Subject: slight clean-up in wget downloading handling --- urpm/download.pm | 15 ++++++++------- urpm/dudf.pm | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/urpm/download.pm b/urpm/download.pm index 01f3644d..30930077 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -457,6 +457,7 @@ sub sync_curl { #- http files (and other files) are correctly managed by curl wrt conditional download. #- options for ftp files, -R (-O )* #- options for http files, -R (-O )* + my $result; if (my @all_files = ( (map { ("-O", $_) } @ftp_files), (map { m|/| ? ("-O", $_) : @{[]} } @other_files))) @@ -480,15 +481,14 @@ sub sync_curl { "--stderr", "-", # redirect everything to stdout @all_files); $options->{debug} and $options->{debug}($cmd); - _curl_action($cmd,$options,@l,"download",$cwd); - } else { - chdir $cwd; + $result = _curl_action($cmd,$options,@l); } - + chdir $cwd; + $result; } sub _curl_action { - my ($cmd, $options, @l, $updown, $cwd) = @_; + my ($cmd, $options, @l, $o_is_upload) = @_; my ($buf, $file); $buf = ''; my $curl_pid = open(my $curl, "$cmd |"); @@ -507,7 +507,9 @@ sub _curl_action { if (propagate_sync_callback($options, 'progress', $file, $percent, $total, $eta, $speed) eq 'canceled') { kill 15, $curl_pid; close $curl; - die N("curl failed: ".$updown." canceled\n"); + + die N("curl failed: upload canceled\n") if $o_is_upload; + die N("curl failed: download canceled\n"); } #- this checks that download has actually started if ($_ eq "\n" @@ -527,7 +529,6 @@ sub _curl_action { $buf = ''; } } - chdir $cwd; close $curl or _error('curl'); } diff --git a/urpm/dudf.pm b/urpm/dudf.pm index f03e35be..8a8aec49 100644 --- a/urpm/dudf.pm +++ b/urpm/dudf.pm @@ -275,7 +275,7 @@ sub upload_dudf { "-F id=" . $self->{dudf_uid}, $self->{upload_url}, ); - urpm::download::_curl_action($cmd, $options, @l, "upload", $cwd); + urpm::download::_curl_action($cmd, $options, @l, 1); unlink $self->{dudf_file} . ".gz"; unlink $self->{dudf_file}; print N("\nYou can see your DUDF report at the following URL :\n\t"); -- cgit v1.2.1