From fda2acf0c8aaf123359470ced37f56e8223a3286 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 21 Jul 2016 13:51:06 +0200 Subject: [feat] use _local couch docs for metadata storage --- common/src/leap/soledad/common/couch/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'common') 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: -- cgit v1.2.3