diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-01-07 12:29:56 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-01-07 12:29:56 -0300 |
commit | f57270eb597dee6104a4c507705ef5d1ba6a7516 (patch) | |
tree | 2e7280c065301306611fd60d614111c19e43acaa /server/src/leap | |
parent | f98f66549d6762bbfc072ef6afe0057798a4da27 (diff) | |
parent | 82628d8284c5c11452da75a6604f2f68b8dd8520 (diff) |
Merge remote-tracking branch 'refs/remotes/drebs/feature/4918_ensure-server-side-locks-use-temporary-directory' into develop
Diffstat (limited to 'server/src/leap')
-rw-r--r-- | server/src/leap/soledad/server/__init__.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/server/src/leap/soledad/server/__init__.py b/server/src/leap/soledad/server/__init__.py index 00d3c8c1..4380966c 100644 --- a/server/src/leap/soledad/server/__init__.py +++ b/server/src/leap/soledad/server/__init__.py @@ -90,6 +90,7 @@ import configparser import time import hashlib import os +import tempfile from u1db.remote import http_app @@ -122,6 +123,7 @@ from leap.soledad.common.errors import ( NotLockedError, AlreadyLockedError, LockTimedOutError, + CouldNotObtainLockError, ) @@ -201,7 +203,9 @@ class LockResource(object): self._shared_db = state.open_database(SoledadApp.SHARED_DB_NAME) self._lock_doc_id = '%s%s' % (SHARED_DB_LOCK_DOC_ID_PREFIX, uuid) self._lock = FilesystemLock( - hashlib.sha512(self._lock_doc_id).hexdigest()) + os.path.join( + tempfile.gettmpdir(), + hashlib.sha512(self._lock_doc_id).hexdigest())) self._state = state self._responder = responder @@ -328,8 +332,10 @@ class LockResource(object): while tries > 0: try: return self._lock.lock() - except Exception as e: + except OSError as e: tries -= 1 + if tries == 0: + raise CouldNotObtainLockError(e.message) time.sleep(self.FILESYSTEM_LOCK_SLEEP_SECONDS) return False |