_moduleLogger.exception("While loading for %s" % self._name)
return
- if misc_utils.compare_versions(
+ if convs and misc_utils.compare_versions(
self.OLDEST_COMPATIBLE_FORMAT_VERSION,
misc_utils.parse_version(fileVersion),
) <= 0:
_moduleLogger.info("%s Loaded cache" % (self._name, ))
self._conversations = convs
self._loadedFromCache = True
- for key, mergedConv in self._conversations.iteritems():
- _moduleLogger.debug("%s \tLoaded %s" % (self._name, key))
- for conv in mergedConv.conversations:
- message = "%s \t\tLoaded %s (%r) %r %r %r" % (
- self._name, conv.id, conv.time, conv.isRead, conv.isArchived, len(conv.messages)
- )
- _moduleLogger.debug(message)
else:
_moduleLogger.debug(
"%s Skipping cache due to version mismatch (%s-%s)" % (
def save(self, path):
_moduleLogger.info("%s Saving cache" % (self._name, ))
+ if not self._conversations:
+ _moduleLogger.info("%s Odd, no conversations to cache. Did we never load the cache?" % (self._name, ))
+ return
+
try:
dataToDump = (constants.__version__, constants.__build__, self._conversations)
with open(path, "wb") as f:
pickle.dump(dataToDump, f, pickle.HIGHEST_PROTOCOL)
except (pickle.PickleError, IOError):
_moduleLogger.exception("While saving for %s" % self._name)
-
- for key, mergedConv in self._conversations.iteritems():
- _moduleLogger.debug("%s \tSaving %s" % (self._name, key))
- for conv in mergedConv.conversations:
- message = "%s \t\tSaving %s (%r) %r %r %r" % (
- self._name, conv.id, conv.time, conv.isRead, conv.isArchived, len(conv.messages)
- )
- _moduleLogger.debug(message)
-
_moduleLogger.info("%s Cache saved" % (self._name, ))
def update(self, force=False):