From 929fa7966aa8b0a619fd50858d51966be2acf2d9 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 21 Feb 2008 14:14:23 +0000 Subject: create _new_distribconf_and_download() and use it (for future commit) --- urpm/media.pm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/urpm/media.pm b/urpm/media.pm index 8ca10605..3d0f5c3e 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -734,13 +734,9 @@ sub add_distrib_media { } else { unlink "$urpm->{cachedir}/partial/media.cfg"; - $distribconf = MDV::Distribconf->new($url, undef); - $distribconf->settree('mandriva'); + $distribconf = _new_distribconf_and_download($urpm, $url); - $urpm->{log}(N("retrieving media.cfg file...")); - if (urpm::download::sync($urpm, undef, - [ reduce_pathname($distribconf->getfullpath(undef, 'infodir') . '/media.cfg') ], - quiet => 1)) { + if ($distribconf) { $distribconf->parse_mediacfg("$urpm->{cachedir}/partial/media.cfg") or $urpm->{error}(N("unable to parse media.cfg")), return(); } else { @@ -805,6 +801,19 @@ sub add_distrib_media { return @newnames; } +sub _new_distribconf_and_download { + my ($urpm, $url) = @_; + + my $distribconf = MDV::Distribconf->new($url, undef); + $distribconf->settree('mandriva'); + + $urpm->{log}(N("retrieving media.cfg file...")); + urpm::download::sync($urpm, undef, + [ reduce_pathname($distribconf->getfullpath(undef, 'infodir') . '/media.cfg') ], + quiet => 1) or return; + $distribconf; +} + #- deprecated, use select_media_by_name instead sub select_media { my $urpm = shift; -- cgit v1.2.1