From 2312bd7c7f01fbf32b23565011d03a29aca2f86e Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 7 Aug 2006 02:42:48 +0000 Subject: [PATCH] =?utf8?q?Cleanse=20stale=20metadata=20cache=20for=20binpk?= =?utf8?q?gs=20that=20have=20been=20removed=20from=20the=20remote=20host.?= =?utf8?q?=20=20Thanks=20to=20Andr=C3=A9=20Luiz=20A.=20G.=20Carvalho=20=20for=20the=20initial=20patch=20from=20bug?= =?utf8?q?=20#107453.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit svn path=/main/trunk/; revision=4182 --- pym/getbinpkg.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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: -- 2.26.2