summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-08-07 21:09:44 -0300
committerVictor Shyba <victor1984@riseup.net>2017-08-07 21:09:44 -0300
commit90c8ebd220b0e15b75e9c1efc6c760f8b6592c4f (patch)
treee0bda12a90c8b3d3a32cf4de08096a3da85a8d97
parentfaa01b5858f9a7a80edb2120f3d767891801b897 (diff)
[bug] skip processing if no consumers to avoid data loss
-rw-r--r--src/leap/soledad/client/incoming.py2
-rw-r--r--testing/tests/client/test_incoming_processing_flow.py8
2 files changed, 10 insertions, 0 deletions
diff --git a/src/leap/soledad/client/incoming.py b/src/leap/soledad/client/incoming.py
index 879684e8..42522303 100644
--- a/src/leap/soledad/client/incoming.py
+++ b/src/leap/soledad/client/incoming.py
@@ -73,6 +73,8 @@ class IncomingBoxProcessingLoop:
@defer.inlineCallbacks
def _process(self):
+ if not self.consumers:
+ defer.returnValue(None)
pending = yield self.incoming_box.list_pending()
for item_id in pending:
item = yield self.incoming_box.fetch_for_processing(item_id)
diff --git a/testing/tests/client/test_incoming_processing_flow.py b/testing/tests/client/test_incoming_processing_flow.py
index 1e64fcc2..40409f0a 100644
--- a/testing/tests/client/test_incoming_processing_flow.py
+++ b/testing/tests/client/test_incoming_processing_flow.py
@@ -77,6 +77,14 @@ class IncomingBoxProcessingTestCase(unittest.TestCase):
self.box.fetch_for_processing.assert_called_once_with('one_item')
@defer.inlineCallbacks
+ def test_no_consumers(self):
+ items = ['one', 'two', 'three']
+ self._set_pending_items(items)
+ yield self.loop()
+ self.box.fetch_for_processing.assert_not_called()
+ self.box.delete.assert_not_called()
+
+ @defer.inlineCallbacks
def test_pending_list_with_multiple_items(self):
items = ['one', 'two', 'three']
self._set_pending_items(items)