summaryrefslogtreecommitdiff
path: root/server/src/leap/soledad
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-03-22 16:34:15 -0300
committerdrebs <drebs@leap.se>2017-04-04 18:27:38 +0200
commitaaa9115cfd4096a4fb6cf0ffbc2c07c75ed3a751 (patch)
tree4edc3cea4624b764a301ee482190c5dfe184eb7c /server/src/leap/soledad
parent5acadaa7716a86448af02c3a078759ddddd45c85 (diff)
[feature] use 409 status code for existing blob id
Raising was generating 500, which is a generic status code for server side errors. This commit adds proper status code of 409 while handling the error on client side by translating the code into a proper exception class.
Diffstat (limited to 'server/src/leap/soledad')
-rw-r--r--server/src/leap/soledad/server/_blobs.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/server/src/leap/soledad/server/_blobs.py b/server/src/leap/soledad/server/_blobs.py
index 4317deff..25266b18 100644
--- a/server/src/leap/soledad/server/_blobs.py
+++ b/server/src/leap/soledad/server/_blobs.py
@@ -52,10 +52,6 @@ logger = Logger()
# [ ] chunking (should we do it on the client or on the server?)
-class BlobAlreadyExists(Exception):
- pass
-
-
class IBlobsBackend(Interface):
"""
@@ -125,8 +121,9 @@ class FilesystemBlobsBackend(object):
except:
pass
if os.path.isfile(path):
- # XXX return some 5xx code
- raise BlobAlreadyExists()
+ # 409 - Conflict
+ request.setResponseCode(409)
+ return "Blob already exists: %s" % blob_id
used = self.get_total_storage(user)
if used > self.quota:
logger.error("Error 507: Quota exceeded for user: %s" % user)