summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@mandriva.com>2009-07-24 15:47:27 +0000
committerChristophe Fergeau <cfergeau@mandriva.com>2009-07-24 15:47:27 +0000
commit3d17ce895bc56e71299348512e5e367b3ebb1af7 (patch)
tree48d03b2939a8a1292314b8b723603eb1613a21f8
parentdd31480d4c9f48132b5df16caa4ef7734468c3e1 (diff)
downloadurpmi-3d17ce895bc56e71299348512e5e367b3ebb1af7.tar
urpmi-3d17ce895bc56e71299348512e5e367b3ebb1af7.tar.gz
urpmi-3d17ce895bc56e71299348512e5e367b3ebb1af7.tar.bz2
urpmi-3d17ce895bc56e71299348512e5e367b3ebb1af7.tar.xz
urpmi-3d17ce895bc56e71299348512e5e367b3ebb1af7.zip
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
-rw-r--r--NEWS2
-rw-r--r--urpm/mirrors.pm5
2 files changed, 7 insertions, 0 deletions
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) = @_;