summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2016-11-20 18:11:16 -0300
committerVictor Shyba <victor1984@riseup.net>2016-11-20 18:11:16 -0300
commit93f696e79b4f5c08fadd046761b3be246c886d93 (patch)
treeccb530aa6c56b21fcf9fb261b6c24bf3b6430bde
parente1daa8e58a412e983a5cdc8bfc8ffa03ab648a45 (diff)
[refactor] Remove dead code
Batching is now decided on server side, so the code can be simplified. Also, sync_db and other parameters were used to initialize encdecpool, which is no longer supported.
-rw-r--r--client/src/leap/soledad/client/http_target/__init__.py19
-rw-r--r--client/src/leap/soledad/client/http_target/send.py14
-rw-r--r--client/src/leap/soledad/client/sqlcipher.py8
3 files changed, 8 insertions, 33 deletions
diff --git a/client/src/leap/soledad/client/http_target/__init__.py b/client/src/leap/soledad/client/http_target/__init__.py
index 91d87f0c..0e250bf1 100644
--- a/client/src/leap/soledad/client/http_target/__init__.py
+++ b/client/src/leap/soledad/client/http_target/__init__.py
@@ -54,8 +54,7 @@ class SoledadHTTPSyncTarget(SyncTargetAPI, HTTPDocSender, HTTPDocFetcher):
the parsed documents that the remote send us, before being decrypted and
written to the main database.
"""
- def __init__(self, url, source_replica_uid, creds, crypto, cert_file,
- sync_db=None):
+ def __init__(self, url, source_replica_uid, creds, crypto, cert_file):
"""
Initialize the sync target.
@@ -68,17 +67,11 @@ class SoledadHTTPSyncTarget(SyncTargetAPI, HTTPDocSender, HTTPDocFetcher):
:type creds: creds
:param crypto: An instance of SoledadCrypto so we can encrypt/decrypt
document contents when syncing.
- :type crypto: soledad.crypto.SoledadCrypto
+ :type crypto: soledad._crypto.SoledadCrypto
:param cert_file: Path to the certificate of the ca used to validate
the SSL certificate used by the remote soledad
server.
:type cert_file: str
- :param sync_db: Optional. handler for the db with the symmetric
- encryption of the syncing documents. If
- None, encryption will be done in-place,
- instead of retreiving it from the dedicated
- database.
- :type sync_db: Sqlite handler
"""
if url.endswith("/"):
url = url[:-1]
@@ -90,15 +83,9 @@ class SoledadHTTPSyncTarget(SyncTargetAPI, HTTPDocSender, HTTPDocFetcher):
self._crypto = crypto
# TODO: DEPRECATED CRYPTO
self._deprecated_crypto = old_crypto.SoledadCrypto(crypto.secret)
- self._sync_db = sync_db
self._insert_doc_cb = None
- # asynchronous encryption/decryption attributes
- self._decryption_callback = None
- self._sync_decr_pool = None
- # XXX Increasing timeout of simple requests to avoid chances of hitting
- # the duplicated syncing bug. This could be reduced to the 30s default
- # after implementing Cancellable Sync. See #7382
+ # Twisted default Agent with our own ssl context factory
self._http = Agent(reactor,
get_compatible_ssl_context_factory(cert_file))
diff --git a/client/src/leap/soledad/client/http_target/send.py b/client/src/leap/soledad/client/http_target/send.py
index b9ca7da2..2b286ec5 100644
--- a/client/src/leap/soledad/client/http_target/send.py
+++ b/client/src/leap/soledad/client/http_target/send.py
@@ -33,8 +33,6 @@ class HTTPDocSender(object):
They need to be encrypted and metadata prepared before sending.
"""
- MAX_BATCH_SIZE = 0 # disabled by now, this is being tested yet
-
# The uuid of the local replica.
# Any class inheriting from this one should provide a meaningful attribute
# if the sync status event is meant to be used somewhere else.
@@ -63,14 +61,10 @@ class HTTPDocSender(object):
@defer.inlineCallbacks
def _send_batch(self, body, docs):
- total = len(docs)
- missing = total - body.consumed
- calls = []
- for i in xrange(1, missing + 1):
- idx = body.consumed + i
- entry = docs[idx - 1]
+ total, calls = len(docs), []
+ for i, entry in enumerate(docs):
calls.append((self._prepare_one_doc,
- entry, body, idx, total))
+ entry, body, i + 1, total))
result = yield self._send_request(body, calls)
_emit_send_status(self.uuid, body.consumed, total)
@@ -101,8 +95,6 @@ class HTTPDocSender(object):
if doc.is_tombstone():
defer.returnValue((doc, None))
else:
- # TODO -- for blobs, should stream the doc raw content
- # TODO -- get rid of this json encoding
content = yield self._crypto.encrypt_doc(doc)
defer.returnValue((doc, content))
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py
index b9db3674..e7057a8d 100644
--- a/client/src/leap/soledad/client/sqlcipher.py
+++ b/client/src/leap/soledad/client/sqlcipher.py
@@ -396,8 +396,7 @@ class SQLCipherU1DBSync(SQLCipherDatabase):
"""
ENCRYPT_LOOP_PERIOD = 1
- def __init__(self, opts, soledad_crypto, replica_uid, cert_file,
- sync_db=None):
+ def __init__(self, opts, soledad_crypto, replica_uid, cert_file):
self._opts = opts
self._path = opts.path
@@ -405,8 +404,6 @@ class SQLCipherU1DBSync(SQLCipherDatabase):
self.__replica_uid = replica_uid
self._cert_file = cert_file
- self._sync_db = sync_db
-
# storage for the documents received during a sync
self.received_docs = []
@@ -494,8 +491,7 @@ class SQLCipherU1DBSync(SQLCipherDatabase):
self._replica_uid,
creds=creds,
crypto=self._crypto,
- cert_file=self._cert_file,
- sync_db=self._sync_db))
+ cert_file=self._cert_file))
#
# Symmetric encryption of syncing docs