Remove path from get_supports_resumeable_download

This commit is contained in:
Joseph Schorr 2014-07-07 16:21:27 -04:00
parent e850d17e29
commit af46d3d455
3 changed files with 15 additions and 20 deletions

View file

@ -100,27 +100,22 @@ def head_image_layer(namespace, repository, image_id, headers):
if permission.can() or model.repository_is_public(namespace, repository):
profile.debug('Looking up repo image')
repo_image = model.get_repo_image(namespace, repository, image_id)
# Add the Accept-Ranges header if the storage engine supports resumeable
# downloads.
extra_headers = {}
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')
extra_headers['Accept-Ranges'] = 'bytes';
resp = make_response('')
resp.headers.extend(extra_headers)
return resp
except (IOError, AttributeError):
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
# downloads.
if store.get_supports_resumeable_downloads(repo_image.storage.locations):
profile.debug('Storage supports resumeable downloads')
extra_headers['Accept-Ranges'] = 'bytes';
resp = make_response('')
resp.headers.extend(extra_headers)
return resp
abort(403)

View file

@ -57,7 +57,7 @@ class BaseStorage(StoragePaths):
def get_direct_download_url(self, path, expires_in=60):
return None
def get_supports_resumeable_downloads(self, path):
def get_supports_resumeable_downloads(self):
return False
def get_content(self, path):

View file

@ -83,7 +83,7 @@ class S3Storage(BaseStorage):
key.set_contents_from_string(content, encrypt_key=True)
return path
def get_supports_resumeable_downloads(self, path):
def get_supports_resumeable_downloads(self):
return True
def get_direct_download_url(self, path, expires_in=60):