summaryrefslogtreecommitdiff
path: root/common/src/leap/soledad/common/couch.py
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/leap/soledad/common/couch.py')
-rw-r--r--common/src/leap/soledad/common/couch.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/common/src/leap/soledad/common/couch.py b/common/src/leap/soledad/common/couch.py
index 0aa84170..3bc1f543 100644
--- a/common/src/leap/soledad/common/couch.py
+++ b/common/src/leap/soledad/common/couch.py
@@ -371,6 +371,7 @@ class CouchDatabase(CommonBackend):
MAX_GET_DOCS_THREADS = 20
update_handler_lock = defaultdict(threading.Lock)
+ sync_info_lock = defaultdict(threading.Lock)
class _GetDocThread(threading.Thread):
"""
@@ -440,7 +441,8 @@ class CouchDatabase(CommonBackend):
if not create:
raise DatabaseDoesNotExist()
server.create(dbname)
- return cls(url, dbname, replica_uid=replica_uid, ensure_ddocs=ensure_ddocs)
+ return cls(
+ url, dbname, replica_uid=replica_uid, ensure_ddocs=ensure_ddocs)
def __init__(self, url, dbname, replica_uid=None, ensure_ddocs=True):
"""
@@ -465,6 +467,10 @@ class CouchDatabase(CommonBackend):
self._database = Database(
urljoin(self._url, self._dbname),
self._session)
+ try:
+ self._database.info()
+ except ResourceNotFound:
+ raise DatabaseDoesNotExist()
if replica_uid is not None:
self._set_replica_uid(replica_uid)
if ensure_ddocs:
@@ -576,6 +582,8 @@ class CouchDatabase(CommonBackend):
_replica_uid = property(_get_replica_uid, _set_replica_uid)
+ replica_uid = property(_get_replica_uid)
+
def _get_generation(self):
"""
Return the current generation.
@@ -869,7 +877,7 @@ class CouchDatabase(CommonBackend):
# Date.prototype.getTime() which was used before inside a couchdb
# update handler.
(int(time.time() * 1000),
- self._allocate_transaction_id()))
+ self._allocate_transaction_id()))
# build the couch document
couch_doc = {
'_id': doc.doc_id,
@@ -1537,8 +1545,8 @@ class CouchServerState(ServerState):
:param dbname: The name of the database to ensure.
:type dbname: str
- :return: The CouchDatabase object and the replica uid.
- :rtype: (CouchDatabase, str)
+ :raise Unauthorized: Always, because Soledad server is not allowed to
+ create databases.
"""
raise Unauthorized()
@@ -1548,6 +1556,9 @@ class CouchServerState(ServerState):
:param dbname: The name of the database to delete.
:type dbname: str
+
+ :raise Unauthorized: Always, because Soledad server is not allowed to
+ delete databases.
"""
raise Unauthorized()