diff options
author | drebs <drebs@leap.se> | 2016-07-21 13:51:06 +0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2016-07-25 09:19:53 -0300 |
commit | fda2acf0c8aaf123359470ced37f56e8223a3286 (patch) | |
tree | bbe88e445c1a310f9d1df16c9c16bdc56ba54f21 /common/src/leap | |
parent | 23fe0be50c7c9408eab47e8286e19b16a77f66ad (diff) |
[feat] use _local couch docs for metadata storage
Diffstat (limited to 'common/src/leap')
-rw-r--r-- | common/src/leap/soledad/common/couch/__init__.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/common/src/leap/soledad/common/couch/__init__.py b/common/src/leap/soledad/common/couch/__init__.py index 523a50a0..21ffd036 100644 --- a/common/src/leap/soledad/common/couch/__init__.py +++ b/common/src/leap/soledad/common/couch/__init__.py @@ -110,6 +110,9 @@ class CouchDatabase(object): CouchDB details from backend code. """ + CONFIG_DOC_ID = '_local/config' + SYNC_DOC_ID_PREFIX = '_local/sync_' + @classmethod def open_database(cls, url, create, ensure_ddocs=False, replica_uid=None, database_security=None): @@ -261,12 +264,12 @@ class CouchDatabase(object): """ try: # set on existent config document - doc = self._database['u1db_config'] + doc = self._database[self.CONFIG_DOC_ID] doc['replica_uid'] = replica_uid except ResourceNotFound: # or create the config document doc = { - '_id': 'u1db_config', + '_id': self.CONFIG_DOC_ID, 'replica_uid': replica_uid, } self._database.save(doc) @@ -280,7 +283,7 @@ class CouchDatabase(object): """ try: # grab replica_uid from server - doc = self._database['u1db_config'] + doc = self._database[self.CONFIG_DOC_ID] replica_uid = doc['replica_uid'] return replica_uid except ResourceNotFound: @@ -499,7 +502,7 @@ class CouchDatabase(object): synchronized with the replica, this is (0, ''). :rtype: (int, str) """ - doc_id = 'u1db_sync_%s' % other_replica_uid + doc_id = '%s%s' % (self.SYNC_DOC_ID_PREFIX, other_replica_uid) try: doc = self._database[doc_id] except ResourceNotFound: @@ -562,7 +565,7 @@ class CouchDatabase(object): generation. :type other_transaction_id: str """ - doc_id = 'u1db_sync_%s' % other_replica_uid + doc_id = '%s%s' % (self.SYNC_DOC_ID_PREFIX, other_replica_uid) try: doc = self._database[doc_id] except ResourceNotFound: |