From b4196026d85a047744bc1c01e81ef61ec6ed894f Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 29 Dec 2013 11:08:46 +0100 Subject: [PATCH] [entropy.client] drop _get_available_packages_hash() --- lib/entropy/client/interfaces/cache.py | 15 +-------------- lib/entropy/client/interfaces/dep.py | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/entropy/client/interfaces/cache.py b/lib/entropy/client/interfaces/cache.py index 1a36e6358..7b50e0f03 100644 --- a/lib/entropy/client/interfaces/cache.py +++ b/lib/entropy/client/interfaces/cache.py @@ -25,17 +25,4 @@ from entropy.db.exceptions import OperationalError, DatabaseError, \ class CacheMixin: - def _get_available_packages_hash(self): - """ - Get available packages cache hash. - """ - # client digest not needed, cache is kept updated - c_hash = "%s|%s|%s|v1" % ( - self.repositories_checksum(), - self.filter_repositories(self.repositories()), - # needed when users do bogus things like editing config files - # manually (branch setting) - self._settings['repositories']['branch']) - sha = hashlib.sha1() - sha.update(const_convert_to_rawstring(repr(c_hash))) - return sha.hexdigest() + pass diff --git a/lib/entropy/client/interfaces/dep.py b/lib/entropy/client/interfaces/dep.py index dff58e9a5..394b8241a 100644 --- a/lib/entropy/client/interfaces/dep.py +++ b/lib/entropy/client/interfaces/dep.py @@ -2871,9 +2871,16 @@ class CalculatorsMixin: [((package_id, repository_id), reason_id), ...] @rtype: list """ - cache_key = "available/masked_%s_v2" % ( - self._get_available_packages_hash(), - ) + sha = hashlib.sha1() + + cache_s = "{%s;%s}v2" % ( + self.repositories_checksum(), + # needed when users do bogus things like editing config files + # manually (branch setting) + self._settings['repositories']['branch']) + sha.update(const_convert_to_rawstring(cache_s)) + + cache_key = "available/masked_%s" % (sha.hexdigest(),) if use_cache and self.xcache: cached = self._cacher.pop(cache_key) @@ -2921,8 +2928,17 @@ class CalculatorsMixin: @return: list of available package matches @rtype: list """ - cache_key = "available_packages/%s" % ( - self._get_available_packages_hash(),) + sha = hashlib.sha1() + + cache_s = "{%s;%s}v2" % ( + self.repositories_checksum(), + # needed when users do bogus things like editing config files + # manually (branch setting) + self._settings['repositories']['branch']) + sha.update(const_convert_to_rawstring(cache_s)) + + cache_key = "available/packages_%s" % (sha.hexdigest(),) + if use_cache and self.xcache: cached = self._cacher.pop(cache_key) if cached is not None: