summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-07-17 16:44:47 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:24 +0200
commit9712b180af268731595a504f2b4e9fdcc0584215 (patch)
tree9e8247ee0b9b6c4ae81262a7c36a9f5842fcb746 /service/pixelated/adapter
parentcf445be6de641fef29b3279cdb3783e33748b489 (diff)
fix test_soledad_querier
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/soledad/soledad_duplicate_removal_mixin.py19
-rw-r--r--service/pixelated/adapter/soledad/soledad_facade_mixin.py2
2 files changed, 13 insertions, 8 deletions
diff --git a/service/pixelated/adapter/soledad/soledad_duplicate_removal_mixin.py b/service/pixelated/adapter/soledad/soledad_duplicate_removal_mixin.py
index 0dd3d497..a2b4b6d7 100644
--- a/service/pixelated/adapter/soledad/soledad_duplicate_removal_mixin.py
+++ b/service/pixelated/adapter/soledad/soledad_duplicate_removal_mixin.py
@@ -14,28 +14,33 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from pixelated.adapter.soledad.soledad_facade_mixin import SoledadDbFacadeMixin
+from twisted.internet import defer
class SoledadDuplicateRemovalMixin(SoledadDbFacadeMixin, object):
+ @defer.inlineCallbacks
def remove_duplicates(self):
for mailbox in ['INBOX', 'DRAFTS', 'SENT', 'TRASH']:
- self._remove_dup_inboxes(mailbox)
- self._remove_dup_recent(mailbox)
+ yield self._remove_dup_inboxes(mailbox)
+ yield self._remove_dup_recent(mailbox)
+ @defer.inlineCallbacks
def _remove_many(self, docs):
- [self.delete_doc(doc) for doc in docs]
+ [(yield self.delete_doc(doc)) for doc in docs]
+ @defer.inlineCallbacks
def _remove_dup_inboxes(self, mailbox_name):
- mailboxes = self.get_mbox(mailbox_name)
+ mailboxes = yield self.get_mbox(mailbox_name)
if len(mailboxes) == 0:
return
mailboxes_to_remove = sorted(mailboxes, key=lambda x: x.content['created'])[1:len(mailboxes)]
- self._remove_many(mailboxes_to_remove)
+ yield self._remove_many(mailboxes_to_remove)
+ @defer.inlineCallbacks
def _remove_dup_recent(self, mailbox_name):
- rct = self.get_recent_by_mbox(mailbox_name)
+ rct = yield self.get_recent_by_mbox(mailbox_name)
if len(rct) == 0:
return
rct_to_remove = sorted(rct, key=lambda x: len(x.content['rct']), reverse=True)[1:len(rct)]
- self._remove_many(rct_to_remove)
+ yield self._remove_many(rct_to_remove)
diff --git a/service/pixelated/adapter/soledad/soledad_facade_mixin.py b/service/pixelated/adapter/soledad/soledad_facade_mixin.py
index d3baa64b..1f191ab2 100644
--- a/service/pixelated/adapter/soledad/soledad_facade_mixin.py
+++ b/service/pixelated/adapter/soledad/soledad_facade_mixin.py
@@ -77,7 +77,7 @@ class SoledadDbFacadeMixin(object):
@defer.inlineCallbacks
def get_lastuid(self, mbox):
if isinstance(mbox, str):
- mbox = (yield defer.maybeDeferred(self.get_mbox(mbox)))[0]
+ mbox = (yield defer.maybeDeferred(self.get_mbox, mbox))[0]
indexer = MailboxIndexer(self.soledad)
last_uuid = yield indexer.get_last_uid(mbox.content['uuid'])