summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-02-17 13:59:06 -0400
committerKali Kaneko <kali@leap.se>2014-02-17 20:42:24 -0400
commit8f5d2d55810ea77932a3828e7d8d89c826b3eca3 (patch)
tree8208058a2de9180d41870a575ae93dda27f90427
parent6a86c99ac5603a8b8c0c7d1ad3fd4e372991b44e (diff)
avoid unneeded db index updates and rdoc creation
-rw-r--r--mail/src/leap/mail/imap/mailbox.py6
-rw-r--r--mail/src/leap/mail/imap/messages.py10
2 files changed, 7 insertions, 9 deletions
diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py
index be8b429..d7be662 100644
--- a/mail/src/leap/mail/imap/mailbox.py
+++ b/mail/src/leap/mail/imap/mailbox.py
@@ -132,14 +132,9 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
:param rw: read-and-write flag for this mailbox
:type rw: int
"""
- logger.debug("Initializing mailbox %r" % (mbox,))
leap_assert(mbox, "Need a mailbox name to initialize")
leap_assert(soledad, "Need a soledad instance to initialize")
- # XXX should move to wrapper
- #leap_assert(isinstance(soledad._db, SQLCipherDatabase),
- #"soledad._db must be an instance of SQLCipherDatabase")
-
self.mbox = self._parse_mailbox_name(mbox)
self.rw = rw
@@ -168,7 +163,6 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
# purge memstore from empty fdocs.
self._memstore.purge_fdoc_store(mbox)
- logger.debug("DONE initializing mailbox %r" % (mbox,))
@property
def listeners(self):
diff --git a/mail/src/leap/mail/imap/messages.py b/mail/src/leap/mail/imap/messages.py
index fc1ec55..9bd64fc 100644
--- a/mail/src/leap/mail/imap/messages.py
+++ b/mail/src/leap/mail/imap/messages.py
@@ -686,6 +686,8 @@ class MessageCollection(WithMsgFields, IndexedDB, MailParser, MBoxParser):
_rdoc_lock = threading.Lock()
_rdoc_property_lock = threading.Lock()
+ _initialized = {}
+
def __init__(self, mbox=None, soledad=None, memstore=None):
"""
Constructor for MessageCollection.
@@ -725,10 +727,12 @@ class MessageCollection(WithMsgFields, IndexedDB, MailParser, MBoxParser):
self.memstore = memstore
self.__rflags = None
- self.initialize_db()
- # ensure that we have a recent-flags and a hdocs-sec doc
- self._get_or_create_rdoc()
+ if not self._initialized.get(mbox, False):
+ self.initialize_db()
+ # ensure that we have a recent-flags and a hdocs-sec doc
+ self._get_or_create_rdoc()
+ self._initialized[mbox] = True
from twisted.internet import reactor
self.reactor = reactor