diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-02-13 17:25:14 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-02-13 17:25:14 -0300 |
commit | 198611dab96c26beb31dae843a07952a9bde3f5a (patch) | |
tree | ea982367e2c411be8ccd184322f5b7cd34d70c9f /mail | |
parent | 5c29bf0cfe91032764052bc925754d728276d149 (diff) | |
parent | 3d4f2123166c8e57ce2c9dfc57f52b91525cf316 (diff) |
Merge remote-tracking branch 'refs/remotes/kali/feature/get-sizes' into develop
Diffstat (limited to 'mail')
-rw-r--r-- | mail/src/leap/mail/imap/memorystore.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/mail/src/leap/mail/imap/memorystore.py b/mail/src/leap/mail/imap/memorystore.py index 3eba59a0..ed2b3f20 100644 --- a/mail/src/leap/mail/imap/memorystore.py +++ b/mail/src/leap/mail/imap/memorystore.py @@ -106,6 +106,12 @@ class MemoryStore(object): # Internal Storage: messages self._msg_store = {} + # Sizes + """ + {'mbox, uid': <int>} + """ + self._sizes = {} + # Internal Storage: payload-hash """ {'phash': weakreaf.proxy(dict)} @@ -348,8 +354,12 @@ class MemoryStore(object): for key in seq: if key in store and empty(store.get(key)): store.pop(key) + prune((FDOC, HDOC, CDOCS, DOCS_ID), store) + # Update memory store size + self._sizes[key] = size(self._msg_store[key]) + def get_docid_for_fdoc(self, mbox, uid): """ Return Soledad document id for the flags-doc for a given mbox and uid, @@ -418,6 +428,9 @@ class MemoryStore(object): self._new.discard(key) self._dirty.discard(key) self._msg_store.pop(key, None) + if key in self._sizes: + del self._sizes[key] + except Exception as exc: logger.exception(exc) @@ -981,4 +994,4 @@ class MemoryStore(object): :rtype: int """ - return size.get_size(self._msg_store) + return reduce(lambda x, y: x + y, self._sizes, 0) |