From 3d17ce895bc56e71299348512e5e367b3ebb1af7 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Fri, 24 Jul 2009 15:47:27 +0000 Subject: invalidate mirrorlist cache when distro version changes If mirrors.cache contains mirrors for 2009.1 and product.id changes to have version=2010.0, cache is used and urpmi.addmedia --distrib --mirrorlist will add 2009.1 mirrors. Store mtime of product.id in the mirror cache to properly detect when product.id was modified --- NEWS | 2 ++ urpm/mirrors.pm | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 830bdcdc..91592f94 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- properly invalidate mirror cache when the distro version changes + (ie when product.id changes). Fixes bug #52133, patch from Aurélien Lefebvre - adjust parsing of aria2 output for aria2 1.4, fixes bug #51354, patch from Funda Wang - use urpmi log API for the transaction failed message instead of diff --git a/urpm/mirrors.pm b/urpm/mirrors.pm index 0ea9b58f..8be3b621 100644 --- a/urpm/mirrors.pm +++ b/urpm/mirrors.pm @@ -110,6 +110,7 @@ sub _pick_one_ { # 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->{product_id_mtime} = _product_id_mtime(); } $cache->{chosen} = $cache->{list}[0]{url} or return; @@ -145,6 +146,9 @@ sub _cache__may_clean_if_outdated { time() > $cache->{time} + 24*60*60 * $urpm->{options}{'days-between-mirrorlist-update'}) { $urpm->{log}("not using outdated cached mirror list $mirrorlist"); %$cache = (); + } elsif ($cache->{product_id_mtime} && _product_id_mtime() != $cache->{product_id_mtime}) { + $urpm->{log}("not using cached mirror list $mirrorlist since product id file changed"); + %$cache = (); } } $cache; @@ -299,6 +303,7 @@ sub _is_only_one_mirror { } sub _network_mtime() { (stat('/etc/resolv.conf'))[9] } +sub _product_id_mtime() { (stat('/etc/product.id'))[9] } sub parse_LDAP_namespace_structure { my ($s) = @_; -- cgit v1.2.1