diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-08-08 10:39:21 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-08-08 10:39:21 -0300 |
commit | ba304610e14f5054ec7143151b52b4bf5473d5f1 (patch) | |
tree | bf504172f153a6c983fe0476cc3494485c730736 | |
parent | 22e27a6f1ca4b5b53ac752e59ee7c21a1ed2d370 (diff) | |
parent | eba7034d6c5c843658c9112a9ead5e2a71d884be (diff) |
Merge remote-tracking branch 'kali/bug/fix-imap-incoming-processing-r2' into develop
-rw-r--r-- | mail/src/leap/mail/imap/fetch.py | 19 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/service/imap.py | 5 |
2 files changed, 15 insertions, 9 deletions
diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py index 1c41813..44b3124 100644 --- a/mail/src/leap/mail/imap/fetch.py +++ b/mail/src/leap/mail/imap/fetch.py @@ -92,7 +92,7 @@ class LeapIncomingMail(object): """ Stops the loop that fetches mail. """ - if self._loop: + if self._loop and self._loop.running is True: self._loop.stop() def _sync_soledad(self): @@ -102,7 +102,7 @@ class LeapIncomingMail(object): try: self._soledad.sync() doclist = self._soledad.get_from_index("just-mail", "*") - #log.msg("there are %s mails" % (len(doclist),)) + log.msg("there are %s mails" % (len(doclist),)) return doclist except ssl.SSLError as exc: logger.warning('SSL Error while syncing soledad: %r' % (exc,)) @@ -116,16 +116,20 @@ class LeapIncomingMail(object): def _process_doclist(self, doclist): log.msg('processing doclist') if not doclist: + logger.debug("no docs found") return for doc in doclist: + logger.debug("processing doc: %s" % doc) keys = doc.content.keys() if self.ENC_SCHEME_KEY in keys and self.ENC_JSON_KEY in keys: # XXX should check for _enc_scheme == "pubkey" || "none" # that is what incoming mail uses. encdata = doc.content[self.ENC_JSON_KEY] - d = defer.Deferred(self._decrypt_msg, doc, encdata) - d.addCallback(self._process_decrypted) + d = defer.Deferred(self._decrypt_msg(doc, encdata)) + d.addCallbacks(self._process_decrypted, log.msg) + else: + logger.debug('This does not look like a proper msg.') def _decrypt_msg(self, doc, encdata): log.msg('decrypting msg') @@ -134,7 +138,9 @@ class LeapIncomingMail(object): encdata, key, # XXX get from public method instead passphrase=self._soledad._passphrase)) - return doc, decrdata + + # XXX TODO: defer this properly + return self._process_decrypted(doc, decrdata) def _process_decrypted(self, doc, data): """ @@ -162,10 +168,9 @@ class LeapIncomingMail(object): if not rawmsg: return False logger.debug('got incoming message: %s' % (rawmsg,)) - #log.msg("we got raw message") # add to inbox and delete from soledad - self.inbox.addMessage(rawmsg, (self.RECENT_FLAG,)) + self._inbox.addMessage(rawmsg, (self.RECENT_FLAG,)) doc_id = doc.doc_id self._soledad.delete_doc(doc) log.msg("deleted doc %s from incoming" % doc_id) diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py index 9e331b6..2ae3012 100644 --- a/mail/src/leap/mail/imap/service/imap.py +++ b/mail/src/leap/mail/imap/service/imap.py @@ -34,8 +34,9 @@ from leap.soledad import Soledad IMAP_PORT = 9930 # The default port in which imap service will run -# INCOMING_CHECK_PERIOD = 5 -INCOMING_CHECK_PERIOD = 60 +# TODO: Make this configurable +INCOMING_CHECK_PERIOD = 5 +#INCOMING_CHECK_PERIOD = 60 # The period between succesive checks of the incoming mail # queue (in seconds) |