diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-02-05 15:29:49 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-02-05 15:29:49 -0300 |
commit | 621fd3a9099f980fa4d0a2402713e1778913d489 (patch) | |
tree | 6bac7814c6999180dfaa313d683a554e9e65906d /src/leap/mail/imap/messageparts.py | |
parent | 74428b3176d286312f69e124d4d613c27a1ec93e (diff) | |
parent | 3f9c3ab22523c553dc677d5273dc8d01394d74f7 (diff) |
Merge remote-tracking branch 'refs/remotes/kali/feature/regression-tests' into develop
Diffstat (limited to 'src/leap/mail/imap/messageparts.py')
-rw-r--r-- | src/leap/mail/imap/messageparts.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/leap/mail/imap/messageparts.py b/src/leap/mail/imap/messageparts.py index b07681b..2d9b3a2 100644 --- a/src/leap/mail/imap/messageparts.py +++ b/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, |