Remove path from get_supports_resumeable_download
This commit is contained in:
parent
e850d17e29
commit
af46d3d455
3 changed files with 15 additions and 20 deletions
|
@ -100,16 +100,16 @@ def head_image_layer(namespace, repository, image_id, headers):
|
||||||
if permission.can() or model.repository_is_public(namespace, repository):
|
if permission.can() or model.repository_is_public(namespace, repository):
|
||||||
profile.debug('Looking up repo image')
|
profile.debug('Looking up repo image')
|
||||||
repo_image = model.get_repo_image(namespace, repository, image_id)
|
repo_image = model.get_repo_image(namespace, repository, image_id)
|
||||||
|
if not repo_image:
|
||||||
|
profile.debug('Image not found')
|
||||||
|
abort(404, 'Image %(image_id)s not found', issue='unknown-image',
|
||||||
|
image_id=image_id)
|
||||||
|
|
||||||
|
extra_headers = {}
|
||||||
|
|
||||||
# Add the Accept-Ranges header if the storage engine supports resumeable
|
# Add the Accept-Ranges header if the storage engine supports resumeable
|
||||||
# downloads.
|
# downloads.
|
||||||
extra_headers = {}
|
if store.get_supports_resumeable_downloads(repo_image.storage.locations):
|
||||||
|
|
||||||
profile.debug('Looking up the layer path')
|
|
||||||
try:
|
|
||||||
path = store.image_layer_path(repo_image.storage.uuid)
|
|
||||||
|
|
||||||
if store.get_supports_resumeable_downloads(repo_image.storage.locations, path):
|
|
||||||
profile.debug('Storage supports resumeable downloads')
|
profile.debug('Storage supports resumeable downloads')
|
||||||
extra_headers['Accept-Ranges'] = 'bytes';
|
extra_headers['Accept-Ranges'] = 'bytes';
|
||||||
|
|
||||||
|
@ -117,11 +117,6 @@ def head_image_layer(namespace, repository, image_id, headers):
|
||||||
resp.headers.extend(extra_headers)
|
resp.headers.extend(extra_headers)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
except (IOError, AttributeError):
|
|
||||||
profile.debug('Image not found')
|
|
||||||
abort(404, 'Image %(image_id)s not found', issue='unknown-image',
|
|
||||||
image_id=image_id)
|
|
||||||
|
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class BaseStorage(StoragePaths):
|
||||||
def get_direct_download_url(self, path, expires_in=60):
|
def get_direct_download_url(self, path, expires_in=60):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_supports_resumeable_downloads(self, path):
|
def get_supports_resumeable_downloads(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_content(self, path):
|
def get_content(self, path):
|
||||||
|
|
|
@ -83,7 +83,7 @@ class S3Storage(BaseStorage):
|
||||||
key.set_contents_from_string(content, encrypt_key=True)
|
key.set_contents_from_string(content, encrypt_key=True)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def get_supports_resumeable_downloads(self, path):
|
def get_supports_resumeable_downloads(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_direct_download_url(self, path, expires_in=60):
|
def get_direct_download_url(self, path, expires_in=60):
|
||||||
|
|
Reference in a new issue