diff options
author | drebs <drebs@leap.se> | 2017-12-08 21:54:13 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-12-13 13:43:48 -0200 |
commit | ad1e3a4a4863006b3415e619138c3bae88da3941 (patch) | |
tree | 9ae4b6612f8a15874b47b085c73d542d9c237db0 /src/leap/soledad/server | |
parent | 06ade52b27800ca94c1abf73964975a5bf717f04 (diff) |
[refactor] make delete_blob() return a deferred
Diffstat (limited to 'src/leap/soledad/server')
-rw-r--r-- | src/leap/soledad/server/_blobs.py | 13 | ||||
-rw-r--r-- | src/leap/soledad/server/interfaces.py | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py index c0b3b237..f9166ce0 100644 --- a/src/leap/soledad/server/_blobs.py +++ b/src/leap/soledad/server/_blobs.py @@ -147,6 +147,7 @@ class FilesystemBlobsBackend(object): os.unlink(blob_path + '.flags') except Exception: pass + return defer.succeed(None) def get_blob_size(self, user, blob_id, namespace=''): blob_path = self._get_path(user, blob_id, namespace) @@ -303,13 +304,17 @@ class BlobsResource(resource.Resource): def render_DELETE(self, request): logger.info("http put: %s" % request.path) user, blob_id, namespace = self._validate(request) - try: - self._handler.delete_blob(user, blob_id, namespace=namespace) - return '' - except BlobNotFound: + + def catchBlobNotFound(failure): + failure.trap(BlobNotFound) request.setResponseCode(404) return "Blob doesn't exists: %s" % blob_id + d = self._handler.delete_blob(user, blob_id, namespace=namespace) + d.addCallback(lambda _: request.finish()) + d.addErrback(catchBlobNotFound) + return NOT_DONE_YET + def render_PUT(self, request): logger.info("http put: %s" % request.path) user, blob_id, namespace = self._validate(request) diff --git a/src/leap/soledad/server/interfaces.py b/src/leap/soledad/server/interfaces.py index 3bf6eaa9..f9257c9b 100644 --- a/src/leap/soledad/server/interfaces.py +++ b/src/leap/soledad/server/interfaces.py @@ -69,6 +69,9 @@ class IBlobsBackend(Interface): :type blob_id: str :param namespace: An optional namespace for the blob. :type namespace: str + + :return: A deferred that fires when the blob has been deleted. + :rtype: twisted.internet.defer.Deferred """ def get_blob_size(user, blob_id, namespace=''): |