diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-10-21 16:22:38 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-10-21 16:22:38 +0000 |
commit | e1b77dc67dc7c350c5d3e6acd451785a9c78f340 (patch) | |
tree | 017302f0d6301141e1fd3771ba072a695ba2b011 /urpm | |
parent | 01508b09ee68c55499c1b1a5ea658bb03204b96c (diff) | |
download | urpmi-e1b77dc67dc7c350c5d3e6acd451785a9c78f340.tar urpmi-e1b77dc67dc7c350c5d3e6acd451785a9c78f340.tar.gz urpmi-e1b77dc67dc7c350c5d3e6acd451785a9c78f340.tar.bz2 urpmi-e1b77dc67dc7c350c5d3e6acd451785a9c78f340.tar.xz urpmi-e1b77dc67dc7c350c5d3e6acd451785a9c78f340.zip |
- urpmi, gurpmi
o allow "retry" on aria2 download failure
Diffstat (limited to 'urpm')
-rw-r--r-- | urpm/download.pm | 15 | ||||
-rw-r--r-- | urpm/get_pkgs.pm | 4 | ||||
-rw-r--r-- | urpm/main_loop.pm | 7 | ||||
-rw-r--r-- | urpm/media.pm | 5 |
4 files changed, 25 insertions, 6 deletions
diff --git a/urpm/download.pm b/urpm/download.pm index c7de59db..d7387645 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -685,7 +685,15 @@ sub sync_aria2 { _parse_aria2_output($options, $aria2, $aria2_pid, $medium, $rel_files); chdir $cwd; - close $aria2 or _error('aria2'); + if (!close $aria2) { + my $raw_msg = _error_msg('aria2'); + my $msg = N("Failed to download %s", $rel_files->[0]); + if ($options->{ask_retry} && $options->{ask_retry}($raw_msg, $msg)) { + $options->{is_retry} = 1; + goto &sync_aria2; + } + die $raw_msg; + } } sub _parse_aria2_output { @@ -704,7 +712,8 @@ sub _parse_aria2_output { $file = $medium->{mirrorlist} ? $medium->{mirrorlist} . ': ' . $medium->{'with-dir'} . "/$rel_files->[0]" : "$medium->{url}/$rel_files->[0]"; - propagate_sync_callback($options, 'start', $file); + propagate_sync_callback($options, 'start', $file) + if !delete $options->{is_retry}; } 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*)\]$!) { my ($total, $percent, $speed, $eta) = ($2, $3, $5, $6); @@ -882,7 +891,7 @@ sub sync_rel_to { #- deprecated, use sync_url() or sync_rel() instead #- #- $medium can be undef -#- known options: quiet, resume, callback +#- known options: quiet, resume, callback, ask_retry sub sync { my ($urpm, $medium, $files, %options) = @_; diff --git a/urpm/get_pkgs.pm b/urpm/get_pkgs.pm index e5a9b5b8..9fb81b83 100644 --- a/urpm/get_pkgs.pm +++ b/urpm/get_pkgs.pm @@ -214,7 +214,9 @@ sub _download_packages_of_distant_media { if (urpm::download::sync_rel($urpm, $blist->{medium}, [ urpm::blist_to_filenames($blist) ], dir => "$cachedir/partial", quiet => $options{quiet}, is_versioned => 1, - resume => $urpm->{options}{resume}, callback => $options{callback})) { + resume => $urpm->{options}{resume}, + ask_retry => $options{ask_retry}, + callback => $options{callback})) { $urpm->{log}(N("...retrieving done")); } else { $urpm->{error}(N("...retrieving failed: %s", $@)); diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm index a8d9a2e5..fdb82717 100644 --- a/urpm/main_loop.pm +++ b/urpm/main_loop.pm @@ -101,6 +101,13 @@ foreach my $set (@{$state->{transaction} || []}) { \@error_sources, quiet => $options{verbose} < 0, callback => $callbacks->{trans_log}, + ask_retry => $callbacks->{ask_retry} || sub { + my ($raw_msg, $msg) = @_; + if (my $download_errors = delete $urpm->{download_errors}) { + $raw_msg = join("\n", @$download_errors, ''); + } + $callbacks->{ask_yes_or_no}('', $raw_msg . "\n" . $msg . "\n" . N("Retry?")); + }, ); if (@error_sources) { $_->[0] = urpm::download::hide_password($_->[0]) foreach @error_sources; diff --git a/urpm/media.pm b/urpm/media.pm index 71898729..e44ae246 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -1445,7 +1445,7 @@ sub _download_MD5SUM_and_check { undef; } -#- options: callback, force, nomd5sum, probe_with, quiet +#- options: callback, ask_retry, force, nomd5sum, probe_with, quiet sub _update_medium__parse_if_unmodified__remote { my ($urpm, $medium, $options) = @_; @@ -1563,7 +1563,7 @@ sub _read_cachedir_pubkey { join(',', keys %key_ids); } -#- options: callback, force, nomd5sum, probe_with, quiet, forcekey, nopubkey, wait_lock +#- options: callback, ask_retry, force, nomd5sum, probe_with, quiet, forcekey, nopubkey, wait_lock #- (from _update_medium__parse_if_unmodified__local and _update_medium__parse_if_unmodified__remote) sub _update_medium_ { my ($urpm, $medium, %options) = @_; @@ -1665,6 +1665,7 @@ sub _update_media__handle_some_flags { #- Recognized options : #- all : all medias are being rebuilt #- allow_failures: whereas failing to update a medium is non fatal +#- ask_retry : function called when a download fails. if it returns true, the download is retried #- callback : UI callback #- forcekey : force retrieval of pubkey #- force : try to force rebuilding base files |