Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
soledad
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
leap
soledad
Commits
8a1ab21e
Verified
Commit
8a1ab21e
authored
7 years ago
by
drebs
Browse files
Options
Downloads
Patches
Plain Diff
[refactor] make set_flags() return a deferred
parent
d5a30f59
No related branches found
No related tags found
1 merge request
!169
#9007 - improve and document IBlobsBackend
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/leap/soledad/server/_blobs.py
+19
-9
19 additions, 9 deletions
src/leap/soledad/server/_blobs.py
src/leap/soledad/server/interfaces.py
+3
-0
3 additions, 0 deletions
src/leap/soledad/server/interfaces.py
with
22 additions
and
9 deletions
src/leap/soledad/server/_blobs.py
+
19
−
9
View file @
8a1ab21e
...
...
@@ -320,7 +320,8 @@ class BlobsResource(resource.Resource):
def
catchBlobNotFound
(
failure
):
failure
.
trap
(
BlobNotFound
)
request
.
setResponseCode
(
404
)
return
"
Blob doesn
'
t exists: %s
"
%
blob_id
request
.
write
(
"
Blob doesn
'
t exists: %s
"
%
blob_id
)
request
.
finish
()
d
=
self
.
_handler
.
delete_blob
(
user
,
blob_id
,
namespace
=
namespace
)
d
.
addCallback
(
lambda
_
:
request
.
finish
())
...
...
@@ -357,17 +358,26 @@ class BlobsResource(resource.Resource):
user
,
blob_id
,
namespace
=
self
.
_validate
(
request
)
raw_flags
=
request
.
content
.
read
()
flags
=
json
.
loads
(
raw_flags
)
try
:
self
.
_handler
.
set_flags
(
user
,
blob_id
,
flags
,
namespace
=
namespace
)
except
BlobNotFound
:
# 404 - Not Found
def
catchBlobNotFound
(
failure
):
failure
.
trap
(
BlobNotFound
)
request
.
setResponseCode
(
404
)
return
"
Blob doesn
'
t exists: %s
"
%
blob_id
except
InvalidFlag
as
e
:
request
.
write
(
"
Blob doesn
'
t exists: %s
"
%
blob_id
)
request
.
finish
()
def
catchInvalidFlag
(
failure
):
e
=
failure
.
trap
(
InvalidFlag
)
request
.
setResponseCode
(
406
)
flag
=
e
.
message
return
"
Invalid flag: %s
"
%
str
(
flag
)
return
''
request
.
write
(
"
Invalid flag: %s
"
%
str
(
flag
))
request
.
finish
()
d
=
self
.
_handler
.
set_flags
(
user
,
blob_id
,
flags
,
namespace
=
namespace
)
d
.
addCallback
(
lambda
_
:
request
.
write
(
''
))
d
.
addCallback
(
lambda
_
:
request
.
finish
())
d
.
addErrback
(
catchBlobNotFound
)
d
.
addErrback
(
catchInvalidFlag
)
return
NOT_DONE_YET
def
_error
(
self
,
e
,
request
):
logger
.
error
(
'
Error processing request: %s
'
%
e
.
getErrorMessage
())
...
...
This diff is collapsed.
Click to expand it.
src/leap/soledad/server/interfaces.py
+
3
−
0
View file @
8a1ab21e
...
...
@@ -189,4 +189,7 @@ class IBlobsBackend(Interface):
:type flags: list of str
:param namespace: An optional namespace for the blob.
:type namespace: str
:return: A deferred that fires when the flags have been set.
:rtype: twisted.internet.defer.Deferred
"""
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment