From 98a27c2141b2ef3ba6f1a191aac672350c318fa1 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 26 Feb 2008 19:28:51 +0000 Subject: create _get_removables_or_check_mounted() out of copy_packages_of_removable_media() --- urpm/removable.pm | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'urpm/removable.pm') diff --git a/urpm/removable.pm b/urpm/removable.pm index 28fb553e..cbd56ed2 100644 --- a/urpm/removable.pm +++ b/urpm/removable.pm @@ -151,15 +151,10 @@ sub _examine_removable_medium { } } -#- $list is a [ { pkg_id1 => url1, ... }, { ... }, ... ] -#- where there is one hash for each medium in {media} -sub copy_packages_of_removable_media { - my ($urpm, $list, $sources, $o_ask_for_medium) = @_; - my %removables; +sub _get_removables_or_check_mounted { + my ($urpm, $list) = @_; - #- make sure everything is correct on input... - $urpm->{media} or return; - @{$urpm->{media}} == @$list or return; + my %removables; foreach (0..$#$list) { values %{$list->[$_]} or next; @@ -172,6 +167,20 @@ sub copy_packages_of_removable_media { $urpm->{error}(N("unable to access medium \"%s\"", $medium->{name})), next; } } + %removables; +} + +#- $list is a [ { pkg_id1 => url1, ... }, { ... }, ... ] +#- where there is one hash for each medium in {media} +sub copy_packages_of_removable_media { + my ($urpm, $list, $sources, $o_ask_for_medium) = @_; + + #- make sure everything is correct on input... + $urpm->{media} or return; + @{$urpm->{media}} == @$list or return; + + my %removables = _get_removables_or_check_mounted($urpm, $list); + foreach my $device (keys %removables) { next if $device =~ m![^a-zA-Z0-9_./-]!; #- bad path #- Here we have only removable devices. -- cgit v1.2.1