From 32e6f4f1aba4b84debfbb9f4ff5eaa588cffbe61 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sat, 6 Nov 2010 18:37:32 +0100 Subject: [PATCH] [entropy.db] always discard live cache when closing repository, see bug #1638 --- libraries/entropy/db/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libraries/entropy/db/__init__.py b/libraries/entropy/db/__init__.py index 02abf434d..4be8393df 100644 --- a/libraries/entropy/db/__init__.py +++ b/libraries/entropy/db/__init__.py @@ -631,6 +631,12 @@ class EntropyRepository(EntropyRepositoryBase): except KeyError: pass + def __discardLiveCache(self): + cache_key = self.__getLiveCacheKey() + for key in EntropyRepository._LIVE_CACHE.keys(): + if key.startswith(cache_key): + del EntropyRepository._LIVE_CACHE[key] + def __setLiveCache(self, key, value): EntropyRepository._LIVE_CACHE[self.__getLiveCacheKey() + key] = value @@ -675,6 +681,11 @@ class EntropyRepository(EntropyRepositoryBase): os.remove(self._db_path) except (OSError, IOError,): pass + # live cache must be discarded every time the repository is closed + # in order to avoid data mismatches for long-running processes + # that load and unload Entropy Framework often. + # like "client-updates-daemon". + self.__discardLiveCache() def vacuum(self): """