diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-12-24 20:25:31 -0300 |
---|---|---|
committer | Victor Shyba <victor1984@riseup.net> | 2017-12-24 20:30:02 -0300 |
commit | 3fe71d50842371e0be6b939ba249f5a7284c0f55 (patch) | |
tree | 0786d75af72948fa9bf5a37740f62f21b61a0041 | |
parent | 0058334106f870012b2bbc6a79e4eb6b9dbb03f5 (diff) |
[refactor] use explicit stream direction argument
download was being inferred. It's now being set on each and will raise
an error if node is provided. Also removed a duplication on params
variable.
-rw-r--r-- | src/leap/soledad/client/_db/blobs/__init__.py | 4 | ||||
-rw-r--r-- | src/leap/soledad/server/_streaming_resource.py | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/leap/soledad/client/_db/blobs/__init__.py b/src/leap/soledad/client/_db/blobs/__init__.py index 8d469760..d4eddb8f 100644 --- a/src/leap/soledad/client/_db/blobs/__init__.py +++ b/src/leap/soledad/client/_db/blobs/__init__.py @@ -483,7 +483,8 @@ class BlobManager(BlobsSynchronizer): @defer.inlineCallbacks def _downstream(self, blobs_id_list, namespace=''): uri = urljoin(self.remote_stream, self.user) - params = {'namespace': namespace} if namespace else None + params = {'namespace': namespace} if namespace else {} + params['direction'] = 'download' data = BytesIO(json.dumps(blobs_id_list)) response = yield self._client.post(uri, params=params, data=data) deferreds = [] @@ -501,7 +502,6 @@ class BlobManager(BlobsSynchronizer): def _upstream(self, blobs_id_list, namespace=''): local, secret = self.local, self.secret uri = urljoin(self.remote_stream, self.user) - params = {'namespace': namespace} if namespace else None sizes = yield self.local.get_size_list(blobs_id_list, namespace) convert = get_unarmored_ciphertext_size sizes = map(lambda (blob_id, size): (blob_id, convert(size)), sizes) diff --git a/src/leap/soledad/server/_streaming_resource.py b/src/leap/soledad/server/_streaming_resource.py index 3cf798e3..0ad16343 100644 --- a/src/leap/soledad/server/_streaming_resource.py +++ b/src/leap/soledad/server/_streaming_resource.py @@ -60,7 +60,7 @@ class StreamingResource(Resource): def render_POST(self, request): user = request.postpath[0] namespace = request.args.get('namespace', ['default'])[0] - direction = request.args.get('direction', ['download'])[0] + direction = request.args['direction'][0] if direction == 'download': return self._startDownstream(user, namespace, request) elif direction == 'upload': |