From a137e9ca9ed2e829e2a3b22ba22f4119ee0e26c2 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 19 Jan 2010 21:15:42 -0600 Subject: [PATCH] Switching from deleting caches to version checking the cache --- src/gvoice/conversations.py | 14 ++++++++++++-- support/builddeb.py | 1 - 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gvoice/conversations.py b/src/gvoice/conversations.py index 809d0fc..384fc4e 100644 --- a/src/gvoice/conversations.py +++ b/src/gvoice/conversations.py @@ -10,6 +10,7 @@ try: except ImportError: import pickle +import constants import util.coroutines as coroutines import util.misc as util_misc @@ -33,14 +34,23 @@ class Conversations(object): assert not self._conversations try: with open(path, "rb") as f: - self._conversations = pickle.load(f) + fileVersion, fileBuild, convs = pickle.load(f) except (pickle.PickleError, IOError): _moduleLogger.exception("While loading for %s" % self._name) + return + + if fileVersion == constants.__version__ and fileBuild == constants.__build__: + self._conversations = convs + else: + _moduleLogger.debug( + "%s Skipping cache due to version mismatch (%s-%s)" % (self._name, fileVersion, fileBuild) + ) def save(self, path): try: + dataToDump = (constants.__version__, constants.__build__, self._conversations) with open(path, "wb") as f: - pickle.dump(self._conversations, f, pickle.HIGHEST_PROTOCOL) + pickle.dump(dataToDump, f, pickle.HIGHEST_PROTOCOL) except (pickle.PickleError, IOError): _moduleLogger.exception("While saving for %s" % self._name) diff --git a/support/builddeb.py b/support/builddeb.py index 93f3f02..f105046 100755 --- a/support/builddeb.py +++ b/support/builddeb.py @@ -41,7 +41,6 @@ __changelog__ = """ __postinstall__ = """#!/bin/sh -e gtk-update-icon-cache -f /usr/share/icons/hicolor -rm -Rf ~/.telepathy-theonering/cache rm -f ~/.telepathy-theonering/theonering.log """ -- 1.7.9.5