Adding fancier version checks to allow to the cache to be preserved longer
[theonering] / src / gvoice / conversations.py
index f6fe4b2..fed382b 100644 (file)
@@ -16,7 +16,7 @@ import util.coroutines as coroutines
 import util.misc as misc_utils
 
 
 import util.misc as misc_utils
 
 
-_moduleLogger = logging.getLogger("gvoice.conversations")
+_moduleLogger = logging.getLogger(__name__)
 
 
 class Conversations(object):
 
 
 class Conversations(object):
@@ -36,15 +36,20 @@ class Conversations(object):
                try:
                        with open(path, "rb") as f:
                                fileVersion, fileBuild, convs = pickle.load(f)
                try:
                        with open(path, "rb") as f:
                                fileVersion, fileBuild, convs = pickle.load(f)
-               except (pickle.PickleError, IOError):
+               except (pickle.PickleError, IOError, EOFError, ValueError):
                        _moduleLogger.exception("While loading for %s" % self._name)
                        return
 
                        _moduleLogger.exception("While loading for %s" % self._name)
                        return
 
-               if fileVersion == constants.__version__ and fileBuild == constants.__build__:
+               if misc_utils.compare_versions(
+                       misc_utils.parse_version("0.8.0"),
+                       misc_utils.parse_version(fileVersion),
+               ) <= 0:
                        self._conversations = convs
                else:
                        _moduleLogger.debug(
                        self._conversations = convs
                else:
                        _moduleLogger.debug(
-                               "%s Skipping cache due to version mismatch (%s-%s)" % (self._name, fileVersion, fileBuild)
+                               "%s Skipping cache due to version mismatch (%s-%s)" % (
+                                       self._name, fileVersion, fileBuild
+                               )
                        )
 
        def save(self, path):
                        )
 
        def save(self, path):