summaryrefslogtreecommitdiffstats
path: root/urpm/main_loop.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-06-08 18:51:12 +0000
committerThierry Vignaud <tv@mageia.org>2012-06-08 18:51:12 +0000
commita1c32cf42d6f9aa2a90e24f75c595aade245ad6e (patch)
treec3cb7b20690c0ffa648903e40e259ec401b23589 /urpm/main_loop.pm
parent4953653249dde553842c915b161c1b64ed653ebd (diff)
downloadurpmi-a1c32cf42d6f9aa2a90e24f75c595aade245ad6e.tar
urpmi-a1c32cf42d6f9aa2a90e24f75c595aade245ad6e.tar.gz
urpmi-a1c32cf42d6f9aa2a90e24f75c595aade245ad6e.tar.bz2
urpmi-a1c32cf42d6f9aa2a90e24f75c595aade245ad6e.tar.xz
urpmi-a1c32cf42d6f9aa2a90e24f75c595aade245ad6e.zip
(_download_all) split it out of run()
Diffstat (limited to 'urpm/main_loop.pm')
-rw-r--r--urpm/main_loop.pm61
1 files changed, 33 insertions, 28 deletions
diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm
index c8cc86ac..81d3e621 100644
--- a/urpm/main_loop.pm
+++ b/urpm/main_loop.pm
@@ -74,6 +74,38 @@ sub _download_packages {
(\@error_sources, \@msgs);
}
+sub _download_all {
+ my ($urpm, $blists, $sources, $force, $callbacks) = @_;
+ if ($urpm->{options}{'download-all'}) {
+ $urpm->{cachedir} = $urpm->{'urpmi-root'} . $urpm->{options}{'download-all'};
+ urpm::init_cache_dir($urpm, $urpm->{cachedir});
+ }
+ my (undef, $available) = urpm::sys::df("$urpm->{cachedir}/rpms");
+
+ if (!$urpm->{options}{ignoresize}) {
+ my ($download_size) = urpm::get_pkgs::get_distant_media_filesize($urpm, $blists, $sources);
+ if ($download_size >= $available*1000) {
+ my $p = N("There is not enough space on your filesystem to download all packages (%s needed, %s available).\nAre you sure you want to continue?", formatXiB($download_size), formatXiB($available*1000));
+ $force || urpm::msg::ask_yes_or_no($p) or return 10;
+ }
+ }
+
+ #download packages one by one so that we don't try to download them again
+ #and again if the user has to restart urpmi because of some failure
+ my %downloaded_pkgs;
+ foreach my $blist (@$blists) {
+ foreach my $pkg (keys %{$blist->{pkgs}}) {
+ next if $downloaded_pkgs{$pkg};
+ my $blist_one = [{ pkgs => { $pkg => $blist->{pkgs}{$pkg} }, medium => $blist->{medium} }];
+ my ($error_sources) = _download_packages($urpm, $callbacks, $blist_one, $sources);
+ if (@$error_sources) {
+ return 10;
+ }
+ $downloaded_pkgs{$pkg} = 1;
+ }
+ }
+}
+
# locking is left to callers
sub run {
my ($urpm, $state, $something_was_to_be_done, $ask_unselect, $_requested, $callbacks) = @_;
@@ -104,34 +136,7 @@ sub run {
$callbacks->{post_removable} and $callbacks->{post_removable}->();
if (exists $urpm->{options}{'download-all'}) {
- if ($urpm->{options}{'download-all'}) {
- $urpm->{cachedir} = $urpm->{'urpmi-root'} . $urpm->{options}{'download-all'};
- urpm::init_cache_dir($urpm, $urpm->{cachedir});
- }
- my (undef, $available) = urpm::sys::df("$urpm->{cachedir}/rpms");
-
- if (!$urpm->{options}{ignoresize}) {
- my ($download_size) = urpm::get_pkgs::get_distant_media_filesize($urpm, $blists, \%sources);
- if ($download_size >= $available*1000) {
- my $p = N("There is not enough space on your filesystem to download all packages (%s needed, %s available).\nAre you sure you want to continue?", formatXiB($download_size), formatXiB($available*1000));
- $force || urpm::msg::ask_yes_or_no($p) or return 10;
- }
- }
-
- #download packages one by one so that we don't try to download them again
- #and again if the user has to restart urpmi because of some failure
- my %downloaded_pkgs;
- foreach my $blist (@$blists) {
- foreach my $pkg (keys %{$blist->{pkgs}}) {
- next if $downloaded_pkgs{$pkg};
- my $blist_one = [{ pkgs => { $pkg => $blist->{pkgs}{$pkg} }, medium => $blist->{medium} }];
- my ($error_sources) = _download_packages($urpm, $callbacks, $blist_one, \%sources);
- if (@$error_sources) {
- return 10;
- }
- $downloaded_pkgs{$pkg} = 1;
- }
- }
+ _download_all($urpm, $blists, \%sources, $force, $callbacks);
}
#- now create transaction just before installation, this will save user impression of slowness.