summaryrefslogtreecommitdiff
path: root/src/leap/soledad/backends/leap_backend.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2013-01-25 01:55:04 +0900
committerkali <kali@leap.se>2013-01-25 01:55:04 +0900
commitb9cba4bc7b88420e0ee46a6f03dd4aa2fb1edd1e (patch)
tree136fcde8955f00ac42ca2054a3108bd4bc0de064 /src/leap/soledad/backends/leap_backend.py
parentb093b632049e1cf4c61d714c025831fb8d373ed7 (diff)
parentd02402a147bbae945618befdb8a1a260a91ce7a6 (diff)
Merge branch 'develop' of ssh://leap.se/leap_client into develop
Diffstat (limited to 'src/leap/soledad/backends/leap_backend.py')
-rw-r--r--src/leap/soledad/backends/leap_backend.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/leap/soledad/backends/leap_backend.py b/src/leap/soledad/backends/leap_backend.py
index 7e98dd45..ec26dca4 100644
--- a/src/leap/soledad/backends/leap_backend.py
+++ b/src/leap/soledad/backends/leap_backend.py
@@ -8,7 +8,6 @@ from u1db.remote import utils
from u1db.remote.http_target import HTTPSyncTarget
from u1db.remote.http_database import HTTPDatabase
from u1db.errors import BrokenSyncStream
-from leap.soledad.util import GPGWrapper
import uuid
@@ -29,9 +28,10 @@ class LeapDocument(Document):
"""
def __init__(self, doc_id=None, rev=None, json='{}', has_conflicts=False,
- encrypted_json=None, soledad=None):
+ encrypted_json=None, soledad=None, syncable=True):
super(LeapDocument, self).__init__(doc_id, rev, json, has_conflicts)
self._soledad = soledad
+ self._syncable = syncable
if encrypted_json:
self.set_encrypted_json(encrypted_json)
@@ -55,6 +55,18 @@ class LeapDocument(Document):
plaintext = self._soledad.decrypt_symmetric(self.doc_id, ciphertext)
return self.set_json(plaintext)
+ def _get_syncable(self):
+ return self._syncable
+
+ def _set_syncable(self, syncable=True):
+ self._syncable = syncable
+
+ syncable = property(
+ _get_syncable,
+ _set_syncable,
+ doc="Determine if document should be synced with server."
+ )
+
class LeapDatabase(HTTPDatabase):
"""Implement the HTTP remote database API to a Leap server."""
@@ -168,10 +180,11 @@ class LeapSyncTarget(HTTPSyncTarget):
ensure=ensure_callback is not None)
comma = ','
for doc, gen, trans_id in docs_by_generations:
- # encrypt before sending to server.
- size += prepare(id=doc.doc_id, rev=doc.rev,
- content=doc.get_encrypted_json(),
- gen=gen, trans_id=trans_id)
+ if doc.syncable:
+ # encrypt before sending to server.
+ size += prepare(id=doc.doc_id, rev=doc.rev,
+ content=doc.get_encrypted_json(),
+ gen=gen, trans_id=trans_id)
entries.append('\r\n]')
size += len(entries[-1])
self._conn.putheader('content-length', str(size))