From e3c7a9fca9087dbf613803444c03cdefd3ec263b Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 26 Feb 2008 22:37:00 +0000 Subject: _check_notfound should be pure, there is no reason for _sort_media should mount any removable media. so introducing _mount_and_check_notfound() --- urpm/removable.pm | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'urpm') diff --git a/urpm/removable.pm b/urpm/removable.pm index e0a5543b..7b3bee2f 100644 --- a/urpm/removable.pm +++ b/urpm/removable.pm @@ -83,25 +83,26 @@ sub try_umounting_removables { delete $urpm->{removable_mounted}; } -#- examine if given medium is already inside a removable device. -#- #- side-effects: #- + those of try_mounting ($urpm->{removable_mounted}, "mount") -sub _check_notfound { +sub _mount_and_check_notfound { my ($urpm, $medium_list, $dir, $removable) = @_; - if ($dir) { - try_mounting($urpm, $dir, $removable); - -e $dir or return 2; - } - foreach (values %$medium_list) { - my $dir_ = _filepath($_) or next; - if (!$dir) { - $dir = $dir_; - try_mounting($urpm, $dir, $removable); - } - -r $dir_ or return 1; - } - 0; + + try_mounting($urpm, $dir, $removable); + -e $dir or return 2; + + _check_notfound($urpm, $medium_list); +} + +#- side-effects: none +sub _check_notfound { + my ($urpm, $medium_list) = @_; + + foreach (values %$medium_list) { + my $dir_ = _filepath($_) or next; + -r $dir_ or return 1; + } + 0; } #- removable media have to be examined to keep mounted the one that has @@ -123,7 +124,7 @@ sub _examine_removable_medium { } #- side-effects: "eject" -#- + those of _check_notfound ($urpm->{removable_mounted}, "mount") +#- + those of _mount_and_check_notfound ($urpm->{removable_mounted}, "mount") #- + those of try_umounting ($urpm->{removable_mounted}, "umount") sub _mount_it { my ($urpm, $medium, $medium_list, $o_ask_for_medium) = @_; @@ -133,7 +134,7 @@ sub _mount_it { #- the directory given does not exist and may be accessible #- by mounting some other directory. Try to figure it out and mount #- everything that might be necessary. - while (_check_notfound($urpm, $medium_list, $dir, $medium->{removable})) { + while (_mount_and_check_notfound($urpm, $medium_list, $dir, $medium->{removable})) { if (is_iso($medium->{removable})) { try_umounting($urpm, $dir); } else { -- cgit v1.2.1