From d59ac3b5ce713787cd7a46e181f2381de3a8fde2 Mon Sep 17 00:00:00 2001 From: drebs Date: Wed, 20 May 2015 10:58:16 -0300 Subject: [feature] ensure reactor stops on client db script --- client/src/leap/soledad/client/encdecpool.py | 9 +++++---- client/src/leap/soledad/client/sqlcipher.py | 1 - scripts/db_access/client_side_db.py | 30 ++++++++++++++++------------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/client/src/leap/soledad/client/encdecpool.py b/client/src/leap/soledad/client/encdecpool.py index 7c21c30e..02eeb590 100644 --- a/client/src/leap/soledad/client/encdecpool.py +++ b/client/src/leap/soledad/client/encdecpool.py @@ -766,11 +766,12 @@ class SyncDecrypterPool(SyncEncryptDecryptPool): # wait until we know how many documents we need to process while self._docs_to_process is None: time.sleep(self.DECRYPT_LOOP_PERIOD) - # because all database operations are asynchronous, we use an event to - # make sure we don't start the next loop before the current one has - # finished. + # because all database operations are asynchronous, we use an + # event to make sure we don't start the next loop before the + # current one has finished. event = threading.Event() - # loop until we have processes as many docs as the number of changes + # loop until we have processes as many docs as the number of + # changes while self._processed_docs < self._docs_to_process: if sameProxiedObjects( self._insert_doc_cb.get(self.source_replica_uid), diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py index 7fde9a7c..96732325 100644 --- a/client/src/leap/soledad/client/sqlcipher.py +++ b/client/src/leap/soledad/client/sqlcipher.py @@ -653,7 +653,6 @@ class SQLCipherU1DBSync(SQLCipherDatabase): # Symmetric encryption of syncing docs # - def get_generation(self): # FIXME # XXX this SHOULD BE a callback diff --git a/scripts/db_access/client_side_db.py b/scripts/db_access/client_side_db.py index 5dd2bd95..1d8d32e2 100644 --- a/scripts/db_access/client_side_db.py +++ b/scripts/db_access/client_side_db.py @@ -214,19 +214,23 @@ def _get_all_docs(soledad): @inlineCallbacks def _main(soledad, km, args): - if args.create_doc: - yield soledad.create_doc({'content': args.create_doc}) - if args.sync: - yield soledad.sync() - if args.get_all_docs: - yield _get_all_docs(soledad) - if args.export_private_key: - yield _export_key(args, km, args.export_private_key, private=True) - if args.export_public_key: - yield _export_key(args, km, args.expoert_public_key, private=False) - if args.export_incoming_messages: - yield _export_incoming_messages(soledad, args.export_incoming_messages) - reactor.stop() + try: + if args.create_doc: + yield soledad.create_doc({'content': args.create_doc}) + if args.sync: + yield soledad.sync() + if args.get_all_docs: + yield _get_all_docs(soledad) + if args.export_private_key: + yield _export_key(args, km, args.export_private_key, private=True) + if args.export_public_key: + yield _export_key(args, km, args.expoert_public_key, private=False) + if args.export_incoming_messages: + yield _export_incoming_messages(soledad, args.export_incoming_messages) + except: + pass + finally: + reactor.stop() if __name__ == '__main__': -- cgit v1.2.3