address PR comments

This commit is contained in:
Jimmy Zelinskie 2016-08-09 15:11:35 -04:00
parent 16b451437f
commit 9f743fd6cd
4 changed files with 19 additions and 16 deletions

View file

@ -33,6 +33,9 @@ _MAX_RESULTS_PER_PAGE = 50
def paginate(limit_kwarg_name='limit', offset_kwarg_name='offset',
callback_kwarg_name='pagination_callback'):
"""
Decorates a handler adding a parsed pagination token and a callback to encode a response token.
"""
def wrapper(func):
@wraps(func)
def wrapped(*args, **kwargs):

View file

@ -343,9 +343,11 @@ def _upload_chunk(blob_upload, start_offset, length):
"""
# Check for invalidate arguments.
if None in {blob_upload, start_offset, length}:
logger.error('None provided as argument to _upload_chunk')
return None
if start_offset > 0 and start_offset > blob_upload.byte_count:
logger.error('start_offset provided to _upload_chunk greater than blob.upload.byte_count')
return None
location_set = {blob_upload.location_name}
@ -391,19 +393,17 @@ def _upload_chunk(blob_upload, start_offset, length):
size_info, fn = calculate_size_handler()
input_fp = wrap_with_handler(input_fp, fn)
try:
length_written, new_metadata, error = storage.stream_upload_chunk(
location_set,
blob_upload.uuid,
start_offset,
length,
input_fp,
blob_upload.storage_metadata,
content_type=BLOB_CONTENT_TYPE,
)
if error is not None:
return None
except InvalidChunkException:
length_written, new_metadata, error = storage.stream_upload_chunk(
location_set,
blob_upload.uuid,
start_offset,
length,
input_fp,
blob_upload.storage_metadata,
content_type=BLOB_CONTENT_TYPE,
)
if error is not None:
logger.error('storage.stream_upload_chunk returned error %s', error)
return None
# If we determined an uncompressed size and this is the first chunk, add it to the blob.

View file

@ -2,9 +2,9 @@
docker implements pure data transformations according to the many Docker specifications.
"""
class DockerException(Exception):
class DockerFormatException(Exception):
pass
class ManifestException(DockerException):
class ManifestException(DockerFormatException):
pass

View file

@ -40,7 +40,7 @@ class SquashedDockerImageFormatter(TarImageFormatter):
# repositories - JSON file containing a repo -> tag -> image map
# {image ID folder}:
# json - The layer JSON
# layer.tar - The tared contents of the layer
# layer.tar - The tarballed contents of the layer
# VERSION - The docker import version: '1.0'
layer_merger = StreamLayerMerger(get_layer_iterator)