diff --git a/data/model/legacy.py b/data/model/legacy.py index a9301eaa4..b4601782e 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -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) diff --git a/endpoints/registry.py b/endpoints/registry.py index edc8c4524..b6978f44d 100644 --- a/endpoints/registry.py +++ b/endpoints/registry.py @@ -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) diff --git a/initdb.py b/initdb.py index 72f529491..5ae3c1ff2 100644 --- a/initdb.py +++ b/initdb.py @@ -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))