diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-09-03 15:16:58 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-09-03 15:16:58 +0000 |
commit | e9249b97b8af7e91c1d69377bb8eb673a3b84458 (patch) | |
tree | 46cff95c090ed057febcda9de7b1c90936489c40 /urpm/download.pm | |
parent | f81967ceaca132aa30ce4622c6a34a6097a2fe8f (diff) | |
download | urpmi-e9249b97b8af7e91c1d69377bb8eb673a3b84458.tar urpmi-e9249b97b8af7e91c1d69377bb8eb673a3b84458.tar.gz urpmi-e9249b97b8af7e91c1d69377bb8eb673a3b84458.tar.bz2 urpmi-e9249b97b8af7e91c1d69377bb8eb673a3b84458.tar.xz urpmi-e9249b97b8af7e91c1d69377bb8eb673a3b84458.zip |
simplify _sync_webfetch_raw() (we know all files to download have the same protocol (ftp, ssh...))
Diffstat (limited to 'urpm/download.pm')
-rw-r--r-- | urpm/download.pm | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/urpm/download.pm b/urpm/download.pm index 745c38be..5389e484 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -839,21 +839,15 @@ sub get_content { sub _sync_webfetch_raw { my ($urpm, $medium, $files, $options) = @_; - my %files; #- currently ftp and http protocols are managed by curl or wget, #- ssh and rsync protocols are managed by rsync *AND* ssh. - foreach (@$files) { - require urpm; - my $proto = urpm::protocol_from_url($_) or die N("unknown protocol defined for %s", $_); - push @{$files{$proto}}, $_; - } - if ($files{file}) { - my @l = map { urpm::file_from_local_url($_) } @{$files{file} || []}; + my $proto = urpm::protocol_from_url($medium->{url}) or die N("unknown protocol defined for %s", $medium->{url}); + + if ($proto eq 'file') { + my @l = map { urpm::file_from_local_url($_) } @$files; eval { sync_file($options, @l) }; $urpm->{fatal}(10, $@) if $@; - delete @files{qw(removable file)}; - } - if ($files{ftp} || $files{http} || $files{https}) { + } elsif (member($proto, 'ftp', 'http', 'https')) { my @available = urpm::download::available_ftp_http_downloaders(); @@ -880,7 +874,7 @@ sub _sync_webfetch_raw { } } my $sync = $urpm::download::{"sync_$preferred"} or die N("no webfetch found, supported webfetch are: %s\n", join(", ", urpm::download::ftp_http_downloaders())); - my @l = (@{$files{ftp} || []}, @{$files{http} || []}, @{$files{https} || []}); + my @l = @$files; # FIXME: This is rather crude and should probably be done some better place. if ($options->{metalink}) { @@ -893,19 +887,14 @@ sub _sync_webfetch_raw { for (my $len = 0; $n < @l && $len < $half_MAX_ARG; $len += length($l[$n++])) {} $sync->($options, splice(@l, 0, $n)); } - - delete @files{qw(ftp http https)}; - } - if ($files{rsync}) { - sync_rsync($options, @{$files{rsync}}); - delete $files{rsync}; - } - if ($files{ssh}) { - my @ssh_files = map { m!^ssh://([^/]*)(.*)! ? "$1:$2" : () } @{$files{ssh}}; + } elsif ($proto eq 'rsync') { + sync_rsync($options, @$files); + } elsif ($proto eq 'ssh') { + my @ssh_files = map { m!^ssh://([^/]*)(.*)! ? "$1:$2" : () } @$files; sync_ssh($options, @ssh_files); - delete $files{ssh}; + } else { + die N("unable to handle protocol: %s", $proto); } - %files and die N("unable to handle protocol: %s", join ', ', keys %files); } sub _take_n_elem { |