summaryrefslogtreecommitdiff
path: root/src/leap/soledad/server
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2017-12-06 19:24:39 -0200
committerdrebs <drebs@leap.se>2017-12-13 13:43:47 -0200
commitfc0725b0827b6f5e02f1d155712b106b3c8854c1 (patch)
treef4347e477725a17d291c5ac0826326430f7e687b /src/leap/soledad/server
parent9f07826cd98448b38646b2c731f82f99ee37f7c4 (diff)
[refactor] make blobs backend list_blobs() agnostic of twisted.web requests
Diffstat (limited to 'src/leap/soledad/server')
-rw-r--r--src/leap/soledad/server/_blobs.py13
-rw-r--r--src/leap/soledad/server/interfaces.py12
2 files changed, 11 insertions, 14 deletions
diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py
index 89c5927e..2ba3fe91 100644
--- a/src/leap/soledad/server/_blobs.py
+++ b/src/leap/soledad/server/_blobs.py
@@ -157,8 +157,8 @@ class FilesystemBlobsBackend(object):
count += len(filter(lambda i: not i.endswith('.flags'), filenames))
return json.dumps({"count": count})
- def list_blobs(self, user, request, namespace='', order_by=None,
- deleted=False, filter_flag=False):
+ def list_blobs(self, user, namespace='', order_by=None, deleted=False,
+ filter_flag=False):
namespace = namespace or 'default'
blob_ids = []
base_path = self._get_path(user, namespace=namespace)
@@ -180,7 +180,7 @@ class FilesystemBlobsBackend(object):
blob_ids = list(self._filter_flag(blob_ids, filter_flag))
blob_ids = [os.path.basename(path).replace('.deleted', '')
for path in blob_ids]
- return json.dumps(blob_ids)
+ return blob_ids
def _filter_flag(self, blob_paths, flag):
for blob_path in blob_paths:
@@ -280,9 +280,10 @@ class BlobsResource(resource.Resource):
order = request.args.get('order_by', [None])[0]
filter_flag = request.args.get('filter_flag', [False])[0]
deleted = request.args.get('deleted', [False])[0]
- return self._handler.list_blobs(user, request, namespace,
- order_by=order, deleted=deleted,
- filter_flag=filter_flag)
+ blobs = self._handler.list_blobs(user, namespace,
+ order_by=order, deleted=deleted,
+ filter_flag=filter_flag)
+ return json.dumps(blobs)
only_flags = request.args.get('only_flags', [False])[0]
try:
if only_flags:
diff --git a/src/leap/soledad/server/interfaces.py b/src/leap/soledad/server/interfaces.py
index f9cc96c4..430cdec3 100644
--- a/src/leap/soledad/server/interfaces.py
+++ b/src/leap/soledad/server/interfaces.py
@@ -112,7 +112,7 @@ class IBlobsBackend(Interface):
:rtype: int
"""
- def list_blobs(user, request, namespace='', order_by=None, deleted=False,
+ def list_blobs(user, namespace='', order_by=None, deleted=False,
filter_flag=None):
"""
List the blobs stored in the backend.
@@ -122,12 +122,8 @@ class IBlobsBackend(Interface):
:param user: The id of the user who owns the blob.
:type user: str
- :param request: A representation of all of the information about the
- request that is being made.
- :type request: twisted.web.server.Request
:param namespace: Restrict the count to a certain namespace.
:type namespace: str
-
:param order_by: 'date' (equivalent to '+date') or '-date', to sort
ascending or descending by date, respectivelly.
:type order_by: str
@@ -137,9 +133,9 @@ class IBlobsBackend(Interface):
be returned.
:type filter_flag: str
- :return: A JSON list of blob ids, optionally ordered and/or restricted
- by namespace.
- :rtype: str
+ :return: A list of blob ids, optionally ordered and/or restricted by
+ namespace.
+ :rtype: list of str
"""
def get_total_storage(user):