From: Zac Medico Date: Mon, 7 Aug 2006 02:42:48 +0000 (-0000) Subject: Cleanse stale metadata cache for binpkgs that have been removed from the remote host... X-Git-Tag: v2.1.1~85 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2312bd7c7f01fbf32b23565011d03a29aca2f86e;p=portage.git Cleanse stale metadata cache for binpkgs that have been removed from the remote host. Thanks to André Luiz A. G. Carvalho for the initial patch from bug #107453. svn path=/main/trunk/; revision=4182 --- diff --git a/pym/getbinpkg.py b/pym/getbinpkg.py index 2fe92b2de..bb9c12e45 100644 --- a/pym/getbinpkg.py +++ b/pym/getbinpkg.py @@ -3,6 +3,8 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +if not hasattr(__builtins__, "set"): + from sets import Set as set from output import * import htmllib,HTMLParser,string,formatter,sys,os,xpak,time,tempfile,base64,urllib2 @@ -511,8 +513,10 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache= break # We may have metadata... now we run through the tbz2 list and check. sys.stderr.write(yellow("cache miss: 'x'")+" --- "+green("cache hit: 'o'")+"\n") + binpkg_filenames = set() for x in tbz2list: x = os.path.basename(x) + binpkg_filenames.add(x) if ((not metadata[baseurl]["data"].has_key(x)) or \ (x not in metadata[baseurl]["data"].keys())): sys.stderr.write(yellow("x")) @@ -525,6 +529,14 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache= sys.stderr.write(red("!!! Failed to retrieve metadata on: ")+str(x)+"\n") else: sys.stderr.write(green("o")) + # Cleanse stale cache for files that don't exist on the server anymore. + stale_cache = set(metadata[baseurl]["data"]).difference(binpkg_filenames) + if stale_cache: + for x in stale_cache: + del metadata[baseurl]["data"][x] + metadata[baseurl]["modified"] = 1 + del stale_cache + del binpkg_filenames sys.stderr.write("\n") try: