From 633b743b69c6fc7bbe2a8ec596df3fc2fc4d95e0 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 9 Jul 2008 08:16:51 +0000 Subject: set network_mtime in _pick_one_, it's cleaner (since we don't need to set cache's network_mtime everytime we use the cache) --- urpm/mirrors.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'urpm/mirrors.pm') diff --git a/urpm/mirrors.pm b/urpm/mirrors.pm index e01c1a68..29e30894 100644 --- a/urpm/mirrors.pm +++ b/urpm/mirrors.pm @@ -45,8 +45,7 @@ sub _pick_one { my @l = split(' ', $mirrorlists); foreach my $mirrorlist (@l) { - if (my $cache = _pick_one_($urpm, $mirrorlist, $allow_cache_update)) { - $mirrorlist ne $l[-1] and $cache->{network_mtime} = _network_mtime(); + if (my $cache = _pick_one_($urpm, $mirrorlist, $allow_cache_update, $mirrorlist ne $l[-1])) { return $cache->{chosen}; } } @@ -56,7 +55,7 @@ sub _pick_one { #- side-effects: $urpm->{mirrors_cache} sub _pick_one_ { - my ($urpm, $mirrorlist, $allow_cache_update) = @_; + my ($urpm, $mirrorlist, $allow_cache_update, $set_network_mtime) = @_; my $cache = _cache__may_clean_if_outdated($urpm, $mirrorlist, $allow_cache_update); @@ -68,6 +67,9 @@ sub _pick_one_ { $cache->{list} = [ _list($urpm, $mirrorlist) ]; } $cache->{time} = time(); + + # the cache will be deemed outdated if network_mtime is more recent than the cache's + $cache->{network_mtime} = _network_mtime() if $set_network_mtime; } $cache->{chosen} = $cache->{list}[0]{url} or return; -- cgit v1.2.1