diff options
author | Christophe Fergeau <cfergeau@mandriva.com> | 2009-10-13 17:00:12 +0000 |
---|---|---|
committer | Christophe Fergeau <cfergeau@mandriva.com> | 2009-10-13 17:00:12 +0000 |
commit | 63b06831d3c1ee0eb8d6cb5f53a5682b512fb5dd (patch) | |
tree | 2e44046606973af463fab13666d0f628b5235890 /urpm | |
parent | d002866b9f38035f7847b4f1b79282edfb6b0594 (diff) | |
download | urpmi-63b06831d3c1ee0eb8d6cb5f53a5682b512fb5dd.tar urpmi-63b06831d3c1ee0eb8d6cb5f53a5682b512fb5dd.tar.gz urpmi-63b06831d3c1ee0eb8d6cb5f53a5682b512fb5dd.tar.bz2 urpmi-63b06831d3c1ee0eb8d6cb5f53a5682b512fb5dd.tar.xz urpmi-63b06831d3c1ee0eb8d6cb5f53a5682b512fb5dd.zip |
check the FS has enough space before trying to download all packages
Diffstat (limited to 'urpm')
-rw-r--r-- | urpm/get_pkgs.pm | 21 | ||||
-rw-r--r-- | urpm/main_loop.pm | 13 |
2 files changed, 32 insertions, 2 deletions
diff --git a/urpm/get_pkgs.pm b/urpm/get_pkgs.pm index 972e1fba..1da874ca 100644 --- a/urpm/get_pkgs.pm +++ b/urpm/get_pkgs.pm @@ -165,6 +165,27 @@ sub verify_partial_rpm_and_move { "$cachedir/rpms/$filename"; } +# get the filesize of packages to download from remote media. +sub get_distant_media_filesize { + my ($urpm, $blists, $sources) = @_; + + my $filesize; + #- get back all ftp and http accessible rpm files into the local cache + foreach my $blist (@$blists) { + #- examine all files to know what can be indexed on multiple media. + while (my ($id, $pkg) = each %{$blist->{pkgs}}) { + #- the given URL is trusted, so the file can safely be ignored. + defined $sources->{$id} and next; + if (!urpm::is_local_medium($blist->{medium})) { + if (my $n = $pkg->filesize) { + $filesize += $n; + } + } + } + } + $filesize; +} + # download packages listed in $blists, # and put the result in $sources or $error_sources # diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm index c34a8e40..f6a5330f 100644 --- a/urpm/main_loop.pm +++ b/urpm/main_loop.pm @@ -98,12 +98,21 @@ sub download_packages { } if ($urpm->{options}{'download-all'}) { - print "Downloading everything!\n"; + 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 $noexpr = N("Nn"); + 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 exit 0; + } + } + my (@error_sources) = download_packages($blists, \%sources); if (@error_sources) { return 10; } - print "Everything downloaded\n"; } #- now create transaction just before installation, this will save user impression of slowness. |