From 8aa665df40a1535012e8dcf990ae21c473631948 Mon Sep 17 00:00:00 2001 From: drebs Date: Fri, 29 Sep 2017 23:33:37 -0300 Subject: [bug] fix argument passing in blobs queries --- src/leap/soledad/client/_db/blobs.py | 11 ++++++----- src/leap/soledad/server/_blobs.py | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/leap/soledad/client/_db/blobs.py b/src/leap/soledad/client/_db/blobs.py index a22c3f0f..60c369b2 100644 --- a/src/leap/soledad/client/_db/blobs.py +++ b/src/leap/soledad/client/_db/blobs.py @@ -259,11 +259,12 @@ class BlobManager(object): """ uri = urljoin(self.remote, self.user + '/') params = {'namespace': namespace} if namespace else {} - params.update({ - 'order_by': order_by, - 'filter_flag': filter_flag, - 'only_count': only_count, - }) + if order_by: + params['order_by'] = order_by + if filter_flag: + params['filter_flag'] = filter_flag + if only_count: + params['only_count'] = only_count response = yield self._client.get(uri, params=params) check_http_status(response.code) defer.returnValue((yield response.json())) diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py index cacfe38d..427c63ca 100644 --- a/src/leap/soledad/server/_blobs.py +++ b/src/leap/soledad/server/_blobs.py @@ -258,7 +258,7 @@ class BlobsResource(resource.Resource): def render_GET(self, request): logger.info("http get: %s" % request.path) user, blob_id, namespace = self._validate(request) - if not blob_id and request.args.get('only_count', False): + if not blob_id and request.args.get('only_count', [False])[0]: return self._handler.count(user, request, namespace) elif not blob_id: order = request.args.get('order_by', [None])[0] @@ -266,7 +266,8 @@ class BlobsResource(resource.Resource): return self._handler.list_blobs(user, request, namespace, order_by=order, filter_flag=filter_flag) - if 'only_flags' in request.args: + only_flags = request.args.get('only_flags', [False])[0] + if only_flags: return self._handler.get_flags(user, blob_id, request, namespace) self._handler.add_tag_header(user, blob_id, request, namespace) return self._handler.read_blob(user, blob_id, request, namespace) -- cgit v1.2.3