summaryrefslogtreecommitdiff
path: root/src/leap/soledad/backends/couch.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-04-23 12:52:06 -0300
committerdrebs <drebs@leap.se>2013-04-23 14:26:46 -0300
commit4c74a91ad905e7d59260ccec789930c16b29a62d (patch)
treede517b9eb258d42c581f7d878f4b8573986649cf /src/leap/soledad/backends/couch.py
parentb48f000e311daf543a8b8f776c5438725485bffd (diff)
Add encryption_scheme property to LeapDocument.
Diffstat (limited to 'src/leap/soledad/backends/couch.py')
-rw-r--r--src/leap/soledad/backends/couch.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/leap/soledad/backends/couch.py b/src/leap/soledad/backends/couch.py
index 6440232d..13b6733c 100644
--- a/src/leap/soledad/backends/couch.py
+++ b/src/leap/soledad/backends/couch.py
@@ -35,6 +35,8 @@ from u1db.remote.server_state import ServerState
from u1db.errors import DatabaseDoesNotExist
from couchdb.client import Server, Document as CouchDocument
from couchdb.http import ResourceNotFound
+
+
from leap.soledad.backends.objectstore import (
ObjectStoreDatabase,
ObjectStoreSyncTarget,
@@ -142,7 +144,8 @@ class CouchDatabase(ObjectStoreDatabase):
doc = self._factory(
doc_id=doc_id,
rev=cdoc['u1db_rev'],
- has_conflicts=has_conflicts)
+ has_conflicts=has_conflicts,
+ encryption_scheme=cdoc['encryption_scheme'])
contents = self._database.get_attachment(cdoc, 'u1db_json')
if contents:
doc.content = json.loads(contents.read())
@@ -192,12 +195,14 @@ class CouchDatabase(ObjectStoreDatabase):
# prepare couch's Document
cdoc = CouchDocument()
cdoc['_id'] = doc.doc_id
- # we have to guarantee that couch's _rev is cosistent
+ # we have to guarantee that couch's _rev is consistent
old_cdoc = self._database.get(doc.doc_id)
if old_cdoc is not None:
cdoc['_rev'] = old_cdoc['_rev']
# store u1db's rev
cdoc['u1db_rev'] = doc.rev
+ # store document's encryption scheme
+ cdoc['encryption_scheme'] = doc.encryption_scheme
# save doc in db
self._database.save(cdoc)
# store u1db's content as json string