Adding fancier version checks to allow to the cache to be preserved longer
[theonering] / src / gvoice / conversations.py
index f64c9f7..fed382b 100644 (file)
@@ -36,15 +36,20 @@ class Conversations(object):
                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
 
-               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(
-                               "%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):