summaryrefslogtreecommitdiff
path: root/common/src/leap/soledad
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2016-08-17 23:00:34 -0300
committerVictor Shyba <victor.shyba@gmail.com>2016-08-17 23:05:21 -0300
commitdc0bae8b6025a060297b55520674cd7238f0186b (patch)
tree7567a099e2dcb93c50fbe144d6a227ed65777fa8 /common/src/leap/soledad
parent29f528927322bb8e3ca326399367c33225b492b5 (diff)
[bug] remove misleading ensure_ddoc
ensure_ddoc doesnt make sense anymore as we dont have any ddoc other than _security, which has its own method for setting. 'ensure_security' is explicit and is set internally when user is creating a database, otherwise it will be False as it's only used during creation. This isn't exposed externally (of couch module) to avoid confusion. This confusion was making create-user-db fail to create a security ddoc as it wasn't passing ensure_ddocs=True. -- Resolves: #8388
Diffstat (limited to 'common/src/leap/soledad')
-rw-r--r--common/src/leap/soledad/common/couch/__init__.py15
-rw-r--r--common/src/leap/soledad/common/couch/state.py2
2 files changed, 7 insertions, 10 deletions
diff --git a/common/src/leap/soledad/common/couch/__init__.py b/common/src/leap/soledad/common/couch/__init__.py
index be30210c..0f4102db 100644
--- a/common/src/leap/soledad/common/couch/__init__.py
+++ b/common/src/leap/soledad/common/couch/__init__.py
@@ -116,7 +116,7 @@ class CouchDatabase(object):
"""
@classmethod
- def open_database(cls, url, create, ensure_ddocs=False, replica_uid=None,
+ def open_database(cls, url, create, replica_uid=None,
database_security=None):
"""
Open a U1DB database using CouchDB as backend.
@@ -127,8 +127,6 @@ class CouchDatabase(object):
:type create: bool
:param replica_uid: an optional unique replica identifier
:type replica_uid: str
- :param ensure_ddocs: Ensure that the design docs exist on server.
- :type ensure_ddocs: bool
:param database_security: security rules as CouchDB security doc
:type database_security: dict
@@ -149,21 +147,20 @@ class CouchDatabase(object):
server.create(dbname)
else:
raise DatabaseDoesNotExist()
- db = cls(url,
- dbname, ensure_ddocs=ensure_ddocs,
+ db = cls(url, dbname, ensure_security=create,
database_security=database_security)
return SoledadBackend(
db, replica_uid=replica_uid)
- def __init__(self, url, dbname, ensure_ddocs=True,
+ def __init__(self, url, dbname, ensure_security=False,
database_security=None):
"""
:param url: Couch server URL with necessary credentials
:type url: string
:param dbname: Couch database name
:type dbname: string
- :param ensure_ddocs: Ensure that the design docs exist on server.
- :type ensure_ddocs: bool
+ :param ensure_security: will PUT a _security ddoc if set
+ :type ensure_security: bool
:param database_security: security rules as CouchDB security doc
:type database_security: dict
"""
@@ -174,7 +171,7 @@ class CouchDatabase(object):
self.batching = False
self.batch_generation = None
self.batch_docs = {}
- if ensure_ddocs:
+ if ensure_security:
self.ensure_security_ddoc(database_security)
def batch_start(self):
diff --git a/common/src/leap/soledad/common/couch/state.py b/common/src/leap/soledad/common/couch/state.py
index 9b40a264..9ff9fe55 100644
--- a/common/src/leap/soledad/common/couch/state.py
+++ b/common/src/leap/soledad/common/couch/state.py
@@ -80,7 +80,7 @@ class CouchServerState(ServerState):
:rtype: SoledadBackend
"""
url = urljoin(self.couch_url, dbname)
- db = CouchDatabase.open_database(url, create=False, ensure_ddocs=False)
+ db = CouchDatabase.open_database(url, create=False)
return db
def ensure_database(self, dbname):