From 6f179bef525b57e049ce4b2ac97853c46a3dc9db Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Fri, 7 Oct 2011 11:06:50 -0400 Subject: don't cache collections by hostname; this could lead to bad data if a host changes OS --- src/lib/Server/Plugins/Packages/Collection.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/lib/Server/Plugins/Packages/Collection.py') diff --git a/src/lib/Server/Plugins/Packages/Collection.py b/src/lib/Server/Plugins/Packages/Collection.py index 69e38134e..aed85fe77 100644 --- a/src/lib/Server/Plugins/Packages/Collection.py +++ b/src/lib/Server/Plugins/Packages/Collection.py @@ -8,7 +8,7 @@ except ImportError: logger = logging.getLogger("Packages") -_collections = dict() +collections = dict() class Collection(object): def __init__(self, metadata, sources, basepath): @@ -278,16 +278,16 @@ class Collection(object): self.sources.sort(cmp, key, reverse) def clear_cache(): - global _collections - _collections = dict() + global collections + collections = dict() def factory(metadata, sources, basepath): - global _collections + global collections if not sources.loaded: # if sources.xml has not received a FAM event yet, defer; # instantiate a dummy Collection object, but do not cache it - # in _collections + # in collections return Collection(metadata, [], basepath) sclasses = set() @@ -298,13 +298,13 @@ def factory(metadata, sources, basepath): relevant.append(source) sclasses.update([source.__class__]) - # _collections is a cache dict of Collection objects that is keyed + # collections is a cache dict of Collection objects that is keyed # off of the set of source urls that apply to each Collection ckeydata = set() for source in relevant: ckeydata.update(source.urls) ckey = tuple(sorted(list(ckeydata))) - if ckey not in _collections: + if ckey not in collections: if len(sclasses) > 1: logger.warning("Multiple source types found for %s: %s" % ",".join([s.__name__ for s in sclasses])) @@ -332,5 +332,5 @@ def factory(metadata, sources, basepath): collection = cclass(metadata, relevant, basepath) # reverse so that file order determines precedence collection.reverse() - _collections[ckey] = collection - return _collections[ckey] + collections[ckey] = collection + return collections[ckey] -- cgit v1.2.3-1-g7c22