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
GitLab 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
d5a30f59
Verified
Commit
d5a30f59
authored
Dec 9, 2017
by
drebs
Browse files
Options
Downloads
Patches
Plain Diff
[refactor] make get_flags() return a deferred
parent
601ed3ed
Branches
Branches containing commit
No related tags found
1 merge request
!169
#9007 - improve and document IBlobsBackend
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/leap/soledad/server/_blobs.py
+9
-5
9 additions, 5 deletions
src/leap/soledad/server/_blobs.py
src/leap/soledad/server/interfaces.py
+2
-2
2 additions, 2 deletions
src/leap/soledad/server/interfaces.py
with
11 additions
and
7 deletions
src/leap/soledad/server/_blobs.py
+
9
−
5
View file @
d5a30f59
...
@@ -101,11 +101,12 @@ class FilesystemBlobsBackend(object):
...
@@ -101,11 +101,12 @@ class FilesystemBlobsBackend(object):
def
get_flags
(
self
,
user
,
blob_id
,
namespace
=
''
):
def
get_flags
(
self
,
user
,
blob_id
,
namespace
=
''
):
path
=
self
.
_get_path
(
user
,
blob_id
,
namespace
)
path
=
self
.
_get_path
(
user
,
blob_id
,
namespace
)
if
not
os
.
path
.
isfile
(
path
):
if
not
os
.
path
.
isfile
(
path
):
r
aise
BlobNotFound
r
eturn
defer
.
fail
(
BlobNotFound
)
if
not
os
.
path
.
isfile
(
path
+
'
.flags
'
):
if
not
os
.
path
.
isfile
(
path
+
'
.flags
'
):
return
[]
return
defer
.
succeed
(
[]
)
with
open
(
path
+
'
.flags
'
,
'
r
'
)
as
flags_file
:
with
open
(
path
+
'
.flags
'
,
'
r
'
)
as
flags_file
:
return
json
.
loads
(
flags_file
.
read
())
flags
=
json
.
loads
(
flags_file
.
read
())
return
defer
.
succeed
(
flags
)
def
set_flags
(
self
,
user
,
blob_id
,
flags
,
namespace
=
''
):
def
set_flags
(
self
,
user
,
blob_id
,
flags
,
namespace
=
''
):
path
=
self
.
_get_path
(
user
,
blob_id
,
namespace
)
path
=
self
.
_get_path
(
user
,
blob_id
,
namespace
)
...
@@ -298,8 +299,11 @@ class BlobsResource(resource.Resource):
...
@@ -298,8 +299,11 @@ class BlobsResource(resource.Resource):
only_flags
=
request
.
args
.
get
(
'
only_flags
'
,
[
False
])[
0
]
only_flags
=
request
.
args
.
get
(
'
only_flags
'
,
[
False
])[
0
]
try
:
try
:
if
only_flags
:
if
only_flags
:
flags
=
self
.
_handler
.
get_flags
(
user
,
blob_id
,
namespace
)
d
=
self
.
_handler
.
get_flags
(
user
,
blob_id
,
namespace
)
return
json
.
dumps
(
flags
)
d
.
addCallback
(
lambda
flags
:
json
.
dumps
(
flags
))
d
.
addCallback
(
lambda
flags
:
request
.
write
(
flags
))
d
.
addCallback
(
lambda
_
:
request
.
finish
())
return
NOT_DONE_YET
tag
=
self
.
_handler
.
get_tag
(
user
,
blob_id
,
namespace
)
tag
=
self
.
_handler
.
get_tag
(
user
,
blob_id
,
namespace
)
request
.
responseHeaders
.
setRawHeaders
(
'
Tag
'
,
[
tag
])
request
.
responseHeaders
.
setRawHeaders
(
'
Tag
'
,
[
tag
])
except
BlobNotFound
:
except
BlobNotFound
:
...
...
This diff is collapsed.
Click to expand it.
src/leap/soledad/server/interfaces.py
+
2
−
2
View file @
d5a30f59
...
@@ -173,8 +173,8 @@ class IBlobsBackend(Interface):
...
@@ -173,8 +173,8 @@ class IBlobsBackend(Interface):
:param namespace: An optional namespace for the blob.
:param namespace: An optional namespace for the blob.
:type namespace: str
:type namespace: str
:return:
a
list of flags.
:return:
A deferred that fires with the
list of flags
for a blob
.
:rtype:
l
ist
of str
:rtype:
tw
ist
ed.internet.defer.Deferred
"""
"""
def
set_flags
(
user
,
blob_id
,
flags
,
namespace
=
''
):
def
set_flags
(
user
,
blob_id
,
flags
,
namespace
=
''
):
...
...
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