summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-02-05 12:37:50 -0400
committerKali Kaneko <kali@leap.se>2014-02-05 14:01:41 -0400
commit012d47df4e9c6ab7d8d1cd315aa9511a670ece00 (patch)
tree9857f09e447571487f42a36ff39870835ce7985e
parentf1c9711c4d77aa514798709687540fcb8da82e05 (diff)
fix memoized call returning always None
-rw-r--r--mail/src/leap/mail/imap/messageparts.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/mail/src/leap/mail/imap/messageparts.py b/mail/src/leap/mail/imap/messageparts.py
index b07681bf..2d9b3a28 100644
--- a/mail/src/leap/mail/imap/messageparts.py
+++ b/mail/src/leap/mail/imap/messageparts.py
@@ -397,7 +397,9 @@ class MessagePart(object):
logger.warning("Could not find phash for this subpart!")
payload = ""
else:
- payload = self._get_payload_from_document(phash)
+ payload = self._get_payload_from_document_memoized(phash)
+ if payload is None:
+ payload = self._get_payload_from_document(phash)
else:
logger.warning("Message with no part_map!")
@@ -424,13 +426,24 @@ class MessagePart(object):
# TODO should memory-bound this memoize!!!
@memoized_method
+ def _get_payload_from_document_memoized(self, phash):
+ """
+ Memoized method call around the regular method, to be able
+ to call the non-memoized method in case we got a None.
+
+ :param phash: the payload hash to retrieve by.
+ :type phash: str or unicode
+ :rtype: str or unicode or None
+ """
+ return self._get_payload_from_document(phash)
+
def _get_payload_from_document(self, phash):
"""
Return the message payload from the content document.
:param phash: the payload hash to retrieve by.
:type phash: str or unicode
- :rtype: str or unicode
+ :rtype: str or unicode or None
"""
cdocs = self._soledad.get_from_index(
fields.TYPE_P_HASH_IDX,