summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-03-18 13:51:08 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-03-18 13:51:08 +0000
commit24b186c4cc1b340f8d8cfeb9f12959b5e4f357e0 (patch)
tree8cda07e77ff63b1dc5c5d02de65432225ad82e80
parent4abf7274e698c8c9c49791783a0c779581fc845c (diff)
downloadurpmi-24b186c4cc1b340f8d8cfeb9f12959b5e4f357e0.tar
urpmi-24b186c4cc1b340f8d8cfeb9f12959b5e4f357e0.tar.gz
urpmi-24b186c4cc1b340f8d8cfeb9f12959b5e4f357e0.tar.bz2
urpmi-24b186c4cc1b340f8d8cfeb9f12959b5e4f357e0.tar.xz
urpmi-24b186c4cc1b340f8d8cfeb9f12959b5e4f357e0.zip
create _cache__may_clean_if_outdated() out of _pick_one()
-rw-r--r--urpm/mirrors.pm25
1 files changed, 19 insertions, 6 deletions
diff --git a/urpm/mirrors.pm b/urpm/mirrors.pm
index 70fa5d13..1a671caa 100644
--- a/urpm/mirrors.pm
+++ b/urpm/mirrors.pm
@@ -42,13 +42,8 @@ sub pick_one {
#- side-effects: $urpm->{mirrors_cache}
sub _pick_one {
my ($urpm, $mirrorlist, $must_succeed, $allow_cache_update) = @_;
- my $cache = _cache($urpm, $mirrorlist);
- if ($allow_cache_update && $cache->{time} &&
- time() > $cache->{time} + 24*60*60 * $urpm->{options}{'days-between-mirrorlist-update'}) {
- $urpm->{log}("not using outdated cached mirror list");
- %$cache = ();
- }
+ my $cache = _cache__may_clean_if_outdated($urpm, $mirrorlist, $allow_cache_update);
if (!$cache->{chosen}) {
if (!$cache->{list}) {
@@ -78,6 +73,24 @@ sub black_list {
@{$cache->{list}} = grep { $_->{url} ne $url } @{$cache->{list}};
delete $cache->{chosen};
}
+
+#- side-effects:
+#- + those of _cache ($urpm->{mirrors_cache})
+sub _cache__may_clean_if_outdated {
+ my ($urpm, $mirrorlist, $allow_cache_update) = @_;
+
+ my $cache = _cache($urpm, $mirrorlist);
+
+ if ($allow_cache_update) {
+ if ($cache->{time} &&
+ time() > $cache->{time} + 24*60*60 * $urpm->{options}{'days-between-mirrorlist-update'}) {
+ $urpm->{log}("not using outdated cached mirror list $mirrorlist");
+ %$cache = ();
+ }
+ }
+ $cache;
+}
+
#- side-effects: $urpm->{mirrors_cache}
sub _cache {
my ($urpm, $mirrorlist) = @_;