summaryrefslogtreecommitdiff
path: root/scripts/db_access/client_side_db.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2015-05-07 14:49:40 -0300
committerdrebs <drebs@leap.se>2015-05-20 10:16:46 -0300
commiteae4468d99029006cc36a021e82350a0f62f7006 (patch)
treedeb6b03134dbb6e7f61f4c339e4d621be885131e /scripts/db_access/client_side_db.py
parent3a7ddacd06fd57afb10cc3d7083c2aa196c9328f (diff)
[bug] fix order of insertion of decrypted docs
This commit actually does some different things: * When doing asynchronous decryption of incoming documents in soledad client during a sync, there was the possibility that a document corresponding to a newer generation would be decrypted and inserted in the local database before a document corresponding to an older generation. When this happened, the metadata about the target database (i.e. its locally-known generation) would be first updated to the newer generation, and then an attempt to insert a document corresponding to an older generation would cause the infamous InvalidGeneration error. To fix that we use the sync-index information that is contained in the sync stream to correctly find the insertable docs to be inserted in the local database, thus avoiding the problem described above. * Refactor the sync encrypt/decrypt pool to its own file. * Fix the use of twisted adbapi with multiprocessing. Closes: #6757.
Diffstat (limited to 'scripts/db_access/client_side_db.py')
-rw-r--r--scripts/db_access/client_side_db.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/db_access/client_side_db.py b/scripts/db_access/client_side_db.py
index d7c54b66..a047b522 100644
--- a/scripts/db_access/client_side_db.py
+++ b/scripts/db_access/client_side_db.py
@@ -10,6 +10,7 @@ import requests
import srp._pysrp as srp
import binascii
import logging
+import json
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
@@ -147,6 +148,9 @@ def _parse_args():
'--passphrase', '-p', default=None,
help='the user passphrase')
parser.add_argument(
+ '--get-all-docs', '-a', action='store_true',
+ help='get all documents from the local database')
+ parser.add_argument(
'--sync', '-s', action='store_true',
help='synchronize with the server replica')
parser.add_argument(
@@ -196,12 +200,21 @@ def _export_incoming_messages(soledad, directory):
i += 1
+@inlineCallbacks
+def _get_all_docs(soledad):
+ _, docs = yield soledad.get_all_docs()
+ for doc in docs:
+ print json.dumps(doc.content, indent=4)
+
+
# main program
@inlineCallbacks
def _main(soledad, km, args):
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: