summaryrefslogtreecommitdiff
path: root/client/src/leap/soledad/client/http_target
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/leap/soledad/client/http_target')
-rw-r--r--client/src/leap/soledad/client/http_target/__init__.py7
-rw-r--r--client/src/leap/soledad/client/http_target/api.py6
-rw-r--r--client/src/leap/soledad/client/http_target/fetch.py15
-rw-r--r--client/src/leap/soledad/client/http_target/send.py5
4 files changed, 20 insertions, 13 deletions
diff --git a/client/src/leap/soledad/client/http_target/__init__.py b/client/src/leap/soledad/client/http_target/__init__.py
index 94de2feb..5dc87fcb 100644
--- a/client/src/leap/soledad/client/http_target/__init__.py
+++ b/client/src/leap/soledad/client/http_target/__init__.py
@@ -54,7 +54,7 @@ class SoledadHTTPSyncTarget(SyncTargetAPI, HTTPDocSender, HTTPDocFetcher):
written to the main database.
"""
def __init__(self, url, source_replica_uid, creds, crypto, cert_file,
- sync_db=None, sync_enc_pool=None):
+ sync_db=None):
"""
Initialize the sync target.
@@ -78,10 +78,6 @@ class SoledadHTTPSyncTarget(SyncTargetAPI, HTTPDocSender, HTTPDocFetcher):
instead of retreiving it from the dedicated
database.
:type sync_db: Sqlite handler
- :param sync_enc_pool: The encryption pool to use to defer encryption.
- If None is passed the encryption will not be
- deferred.
- :type sync_enc_pool: leap.soledad.client.encdecpool.SyncEncrypterPool
"""
if url.endswith("/"):
url = url[:-1]
@@ -92,7 +88,6 @@ class SoledadHTTPSyncTarget(SyncTargetAPI, HTTPDocSender, HTTPDocFetcher):
self.set_creds(creds)
self._crypto = crypto
self._sync_db = sync_db
- self._sync_enc_pool = sync_enc_pool
self._insert_doc_cb = None
# asynchronous encryption/decryption attributes
self._decryption_callback = None
diff --git a/client/src/leap/soledad/client/http_target/api.py b/client/src/leap/soledad/client/http_target/api.py
index 00b943e1..2d51d94f 100644
--- a/client/src/leap/soledad/client/http_target/api.py
+++ b/client/src/leap/soledad/client/http_target/api.py
@@ -42,8 +42,6 @@ class SyncTargetAPI(SyncTarget):
@defer.inlineCallbacks
def close(self):
- if self._sync_enc_pool:
- self._sync_enc_pool.stop()
yield self._http.close()
@property
@@ -68,10 +66,6 @@ class SyncTargetAPI(SyncTarget):
def _base_header(self):
return self._auth_header.copy() if self._auth_header else {}
- @property
- def _defer_encryption(self):
- return self._sync_enc_pool is not None
-
def _http_request(self, url, method='GET', body=None, headers=None,
content_type=None, body_reader=readBody,
body_producer=None):
diff --git a/client/src/leap/soledad/client/http_target/fetch.py b/client/src/leap/soledad/client/http_target/fetch.py
index 50e89a2a..541ec1d2 100644
--- a/client/src/leap/soledad/client/http_target/fetch.py
+++ b/client/src/leap/soledad/client/http_target/fetch.py
@@ -146,7 +146,20 @@ class HTTPDocFetcher(object):
# make sure we have replica_uid from fresh new dbs
if self._ensure_callback and 'replica_uid' in metadata:
self._ensure_callback(metadata['replica_uid'])
- return number_of_changes, new_generation, new_transaction_id
+ # parse incoming document info
+ entries = []
+ for index in xrange(1, len(data[1:]), 2):
+ try:
+ line, comma = utils.check_and_strip_comma(data[index])
+ content, _ = utils.check_and_strip_comma(data[index + 1])
+ entry = json.loads(line)
+ entries.append((entry['id'], entry['rev'], content,
+ entry['gen'], entry['trans_id']))
+ except (IndexError, KeyError):
+ raise errors.BrokenSyncStream
+ return new_generation, new_transaction_id, number_of_changes, \
+ entries
+
def _emit_receive_status(user_data, received_docs, total):
diff --git a/client/src/leap/soledad/client/http_target/send.py b/client/src/leap/soledad/client/http_target/send.py
index fcda9bd7..86744ec2 100644
--- a/client/src/leap/soledad/client/http_target/send.py
+++ b/client/src/leap/soledad/client/http_target/send.py
@@ -15,10 +15,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
+import os
from twisted.internet import defer
+from twisted.persisted import dirdbm
from leap.soledad.common.log import getLogger
+from leap.common.config import get_path_prefix
from leap.soledad.client.events import emit_async
from leap.soledad.client.events import SOLEDAD_SYNC_SEND_STATUS
from leap.soledad.client.http_target.support import RequestBody
@@ -39,6 +42,8 @@ class HTTPDocSender(object):
# Any class inheriting from this one should provide a meaningful attribute
# if the sync status event is meant to be used somewhere else.
+ staging_path = os.path.join(get_path_prefix(), 'leap', 'soledad', 'staging')
+
uuid = 'undefined'
userid = 'undefined'