summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2013-03-21 22:52:45 +0000
committerThierry Vignaud <tv@mageia.org>2013-03-21 22:52:45 +0000
commitdcdf28f560bda2f96936b8ed387b65dc364e12ef (patch)
treec3aae512652bd37ab268adb9f7141b3161e9f01e
parent968cebcee69fea76bc8a2b65d389af59c53bd6a9 (diff)
downloadurpmi-dcdf28f560bda2f96936b8ed387b65dc364e12ef.tar
urpmi-dcdf28f560bda2f96936b8ed387b65dc364e12ef.tar.gz
urpmi-dcdf28f560bda2f96936b8ed387b65dc364e12ef.tar.bz2
urpmi-dcdf28f560bda2f96936b8ed387b65dc364e12ef.tar.xz
urpmi-dcdf28f560bda2f96936b8ed387b65dc364e12ef.zip
enable to cancel downloads
-rw-r--r--NEWS1
-rw-r--r--gurpm/RPMProgressDialog.pm1
-rwxr-xr-xgurpmi213
3 files changed, 14 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 2cb53706..db5cb36c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
- library:
o enable to have a cancel button in global progress bar dialog
- gurpmi2:
+ o enable to cancel downloads
o fix setting download callback
Version 7.21 - 21 March 2013, by Thierry Vignaud
diff --git a/gurpm/RPMProgressDialog.pm b/gurpm/RPMProgressDialog.pm
index 357d4f71..642f3a33 100644
--- a/gurpm/RPMProgressDialog.pm
+++ b/gurpm/RPMProgressDialog.pm
@@ -331,6 +331,7 @@ sub callback_download {
&urpm::download::progress_text($mode, $percent, $total, $eta, $speed));
}
if ($mode eq 'start') {
+ $mainw->validate_cancel(N("Cancel"), \&callback_cancel);
$download_nb++;
$mainw->set_progressbar(0);
select(undef, undef, undef, 0.1); #- hackish
diff --git a/gurpmi2 b/gurpmi2
index ee542818..47bc0225 100755
--- a/gurpmi2
+++ b/gurpmi2
@@ -259,7 +259,8 @@ sub do_install_3 () {
$mainw->init_progressbar;
- my $exit_code = urpm::main_loop::run($urpm, $state, scalar(@gurpmi::names), \@ask_unselect, {
+ my $exit_code;
+ $exit_code = urpm::main_loop::run($urpm, $state, scalar(@gurpmi::names), \@ask_unselect, {
bad_signature => sub {
my ($msg, $msg2) = @_;
$urpm->{log}("$msg\n$msg2");
@@ -276,6 +277,15 @@ sub do_install_3 () {
1;
},
trans_log => \&gurpm::RPMProgressDialog::callback_download,
+ post_download => sub {
+ if ($mainw->canceled) {
+ $exit_code = 10;
+ warn ">> CANCELING\n";
+ goto return_with_exit_code;
+ }
+ $mainw->invalidate_cancel_forever;
+ },
+
ask_yes_or_no => \&ask_yes_or_no,
completed => sub {
@@ -340,6 +350,7 @@ sub do_install_3 () {
exec $0, @ARGV;
}
+return_with_exit_code:
# Show postponed message before exiting
$urpm->{error}->($urpm::postponed_msg) if $urpm::postponed_code != 0;