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 | 7828c517ae162de4676a71e05f77339598acd6f7 (patch) | |
tree | a93a1eb2811888101cd3924dc8b1829a283159bd /src/leap/mail/imap | |
parent | 287022942487c9d350660281c71f918e19f42533 (diff) | |
parent | 498c6745abd91652dfef94045dfe005be0422bf2 (diff) |
Merge remote-tracking branch 'refs/remotes/kali/feature/get-sizes' into develop
Diffstat (limited to 'src/leap/mail/imap')
-rw-r--r-- | src/leap/mail/imap/memorystore.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/leap/mail/imap/memorystore.py b/src/leap/mail/imap/memorystore.py index 3eba59a..ed2b3f2 100644 --- a/src/leap/mail/imap/memorystore.py +++ b/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) |