diff options
| -rw-r--r-- | client/changes/bug_4435_catch-lock-timeout-exception | 1 | ||||
| -rw-r--r-- | client/src/leap/soledad/client/__init__.py | 3 | ||||
| -rw-r--r-- | common/changes/bug_4435_add-lock-timeout-error | 1 | ||||
| -rw-r--r-- | common/src/leap/soledad/common/errors.py | 14 | ||||
| -rw-r--r-- | server/changes/bug_4435_send-timeout-response | 1 | ||||
| -rw-r--r-- | server/src/leap/soledad/server/__init__.py | 5 | 
6 files changed, 23 insertions, 2 deletions
| diff --git a/client/changes/bug_4435_catch-lock-timeout-exception b/client/changes/bug_4435_catch-lock-timeout-exception new file mode 100644 index 00000000..12c05685 --- /dev/null +++ b/client/changes/bug_4435_catch-lock-timeout-exception @@ -0,0 +1 @@ +  o Catch lock timeout exception (#4435). diff --git a/client/src/leap/soledad/client/__init__.py b/client/src/leap/soledad/client/__init__.py index d35d3a2a..11e8585b 100644 --- a/client/src/leap/soledad/client/__init__.py +++ b/client/src/leap/soledad/client/__init__.py @@ -54,6 +54,7 @@ from leap.soledad.common.errors import (      InvalidTokenError,      NotLockedError,      AlreadyLockedError, +    LockTimedOutError,  )  from leap.soledad.common.crypto import (      MacMethods, @@ -410,6 +411,8 @@ class Soledad(object):                  token, timeout = self._shared_db.lock()              except AlreadyLockedError:                  raise BootstrapSequenceError('Database is already locked.') +            except LockTimedOutError: +                raise BootstrapSequenceError('Lock operation timed out.')              try:                  self._get_or_gen_crypto_secrets() diff --git a/common/changes/bug_4435_add-lock-timeout-error b/common/changes/bug_4435_add-lock-timeout-error new file mode 100644 index 00000000..8f220b1d --- /dev/null +++ b/common/changes/bug_4435_add-lock-timeout-error @@ -0,0 +1 @@ +  o Add lock timeout HTTP error (#4435). diff --git a/common/src/leap/soledad/common/errors.py b/common/src/leap/soledad/common/errors.py index 7c2d7296..62de19f8 100644 --- a/common/src/leap/soledad/common/errors.py +++ b/common/src/leap/soledad/common/errors.py @@ -57,14 +57,26 @@ class AlreadyLockedError(errors.U1DBError):      wire_description = "lock is locked"      status = 403 + +class LockTimedOutError(errors.U1DBError): +    """ +    Exception raised when timing out while trying to lock the shared database. +    """ + +    wire_description = "lock timed out" +    status = 408 + +  # update u1db "wire description to status" and "wire description to exception"  # maps. -for e in [InvalidTokenError, NotLockedError, AlreadyLockedError]: +for e in [InvalidTokenError, NotLockedError, AlreadyLockedError, +        LockTimedOutError]:      http_errors.wire_description_to_status.update({          e.wire_description: e.status})      errors.wire_description_to_exc.update({          e.wire_description: e}) +  # u1db error statuses also have to be updated  http_errors.ERROR_STATUSES = set(      http_errors.wire_description_to_status.values()) diff --git a/server/changes/bug_4435_send-timeout-response b/server/changes/bug_4435_send-timeout-response new file mode 100644 index 00000000..ccc74959 --- /dev/null +++ b/server/changes/bug_4435_send-timeout-response @@ -0,0 +1 @@ +  o Send propper lock timeout response (#4435). diff --git a/server/src/leap/soledad/server/__init__.py b/server/src/leap/soledad/server/__init__.py index a4b25fe2..00d3c8c1 100644 --- a/server/src/leap/soledad/server/__init__.py +++ b/server/src/leap/soledad/server/__init__.py @@ -121,6 +121,7 @@ from leap.soledad.common.errors import (      InvalidTokenError,      NotLockedError,      AlreadyLockedError, +    LockTimedOutError,  ) @@ -225,7 +226,9 @@ class LockResource(object):          """          # obtain filesystem lock          if not self._try_obtain_filesystem_lock(): -            self._responder.send_response_json(408)  # error: request timeout +            self._responder.send_response_json( +                LockTimedOutError.status,  # error: request timeout +                error=LockTimedOutError.wire_description)              return          created_lock = False | 
