Move size and checksum updates into the metadata call

This commit is contained in:
Joseph Schorr 2014-09-23 15:49:28 -04:00
parent 74e35f917e
commit ec484e3efc
3 changed files with 8 additions and 11 deletions

View file

@ -1206,8 +1206,8 @@ def set_image_size(docker_image_id, namespace_name, repository_name,
return image
def set_image_metadata(docker_image_id, namespace_name, repository_name,
created_date_str, comment, command, parent=None):
def set_image_metadata(docker_image_id, namespace_name, repository_name, created_date_str, comment,
command, uncompressed_size, parent=None):
with config.app_config['DB_TRANSACTION_FACTORY'](db):
query = (Image
.select(Image, ImageStorage)
@ -1223,9 +1223,12 @@ def set_image_metadata(docker_image_id, namespace_name, repository_name,
except Image.DoesNotExist:
raise DataModelException('No image with specified id and repository')
# We cleanup any old checksum in case it's a retry after a fail
fetched.storage.checksum = None
fetched.storage.created = dateutil.parser.parse(created_date_str).replace(tzinfo=None)
fetched.storage.comment = comment
fetched.storage.command = command
fetched.storage.command = command
fetched.storage.uncompressed_size = uncompressed_size
if parent:
fetched.ancestors = '%s%s/' % (parent.ancestors, parent.id)

View file

@ -451,12 +451,6 @@ def put_image_json(namespace, repository, image_id):
set_uploading_flag(repo_image, True)
# We cleanup any old checksum in case it's a retry after a fail
profile.debug('Cleanup old checksum and save size')
repo_image.storage.uncompressed_size = data.get('Size')
repo_image.storage.checksum = None
repo_image.storage.save()
# If we reach that point, it means that this is a new image or a retry
# on a failed push
# save the metadata
@ -466,7 +460,7 @@ def put_image_json(namespace, repository, image_id):
profile.debug('Setting image metadata')
model.set_image_metadata(image_id, namespace, repository,
data.get('created'), data.get('comment'), command,
parent_image)
data.get('Size'), parent_image)
profile.debug('Putting json path')
store.put_content(repo_image.storage.locations, json_path, request.data)

View file

@ -81,7 +81,7 @@ def __create_subtree(repo, structure, creator_username, parent):
command = json.dumps(command_list) if command_list else None
new_image = model.set_image_metadata(docker_image_id, repo.namespace,
repo.name, str(creation_time),
'no comment', command, parent)
'no comment', command, 0, parent)
model.set_image_size(docker_image_id, repo.namespace, repo.name,
random.randrange(1, 1024 * 1024 * 1024))