Skip to content
Snippets Groups Projects
Commit 65f4b337 authored by Martin Blanchard's avatar Martin Blanchard
Browse files

client/cas.py: Fix empty instance-name issue

If the Uploader or Downloader instance-name parameter is set to the
empty string instead of None, the generated ByteStream resource-name
would contain a leading slash, which is an invalid REAPI request. If
the instance-name is not set, the resource-name should be of the form:

    blobs/{hash}/{size}
parent 23f0fed1
No related branches found
No related tags found
1 merge request!92Fix invalid resource-name isue with empty instance-name
Pipeline #31903247 passed
......@@ -241,7 +241,7 @@ class Downloader:
"""Fetches a blob using ByteStream.Read()"""
read_blob = bytearray()
if self.instance_name is not None:
if self.instance_name:
resource_name = '/'.join([self.instance_name, 'blobs',
digest.hash, str(digest.size_bytes)])
else:
......@@ -313,7 +313,7 @@ class Downloader:
def _fetch_file(self, digest, file_path):
"""Fetches a file using ByteStream.Read()"""
if self.instance_name is not None:
if self.instance_name:
resource_name = '/'.join([self.instance_name, 'blobs',
digest.hash, str(digest.size_bytes)])
else:
......@@ -699,7 +699,7 @@ class Uploader:
else:
blob_digest.hash = HASH(blob).hexdigest()
blob_digest.size_bytes = len(blob)
if self.instance_name is not None:
if self.instance_name:
resource_name = '/'.join([self.instance_name, 'uploads', self.u_uid, 'blobs',
blob_digest.hash, str(blob_digest.size_bytes)])
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment