summaryrefslogtreecommitdiff
path: root/client/src/leap/soledad/client/sqlcipher.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-06-05 11:21:17 -0400
committerKali Kaneko <kali@leap.se>2015-06-15 14:24:20 -0400
commitc0c9769f56814fe570c007b7153f60faebea4881 (patch)
tree947e11e71e965cc429f5473e5828fc550281106c /client/src/leap/soledad/client/sqlcipher.py
parent20a76a36f8dce0ebd0fe63690633c0e77727f2c4 (diff)
[feature] add post-sync hooks using twisted plugins
implementing a generic plugin interface to allow other modules to react to soledad syncs, receiving a list of document ids that they've subscribed to. - Resolves: #6996 - Releases: 0.7.1
Diffstat (limited to 'client/src/leap/soledad/client/sqlcipher.py')
-rw-r--r--client/src/leap/soledad/client/sqlcipher.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py
index b2025130..75d786a6 100644
--- a/client/src/leap/soledad/client/sqlcipher.py
+++ b/client/src/leap/soledad/client/sqlcipher.py
@@ -456,6 +456,9 @@ class SQLCipherU1DBSync(SQLCipherDatabase):
self._syncers = {}
+ # Storage for the documents received during a sync
+ self.received_docs = []
+
self.running = False
self._sync_threadpool = None
self._initialize_sync_threadpool()
@@ -587,8 +590,16 @@ class SQLCipherU1DBSync(SQLCipherDatabase):
# the following context manager blocks until the syncing lock can be
# acquired.
with self._syncer(url, creds=creds) as syncer:
+
+ def _record_received_docs(result):
+ # beware, closure. syncer is in scope.
+ self.received_docs = syncer.received_docs
+ return result
+
# XXX could mark the critical section here...
- return syncer.sync(defer_decryption=defer_decryption)
+ d = syncer.sync(defer_decryption=defer_decryption)
+ d.addCallback(_record_received_docs)
+ return d
@contextmanager
def _syncer(self, url, creds=None):