Merge pull request #3371 from quay/further-storage-fixes

Make absolutely sure we don't overwrite an existing storage checksum
This commit is contained in:
Joseph Schorr 2019-02-16 13:11:31 -05:00 committed by GitHub
commit 410aa151db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -52,6 +52,8 @@ def store_blob_record_and_temp_link(namespace, repo_name, blob_digest, location_
link_expiration_s, uncompressed_byte_count=None): link_expiration_s, uncompressed_byte_count=None):
""" Store a record of the blob and temporarily link it to the specified repository. """ Store a record of the blob and temporarily link it to the specified repository.
""" """
assert blob_digest
with db_transaction(): with db_transaction():
try: try:
storage = ImageStorage.get(content_checksum=blob_digest) storage = ImageStorage.get(content_checksum=blob_digest)
@ -183,6 +185,10 @@ def get_or_create_shared_blob(digest, byte_data, storage):
accessible, such as the special empty gzipped tar layer that Docker accessible, such as the special empty gzipped tar layer that Docker
no longer pushes to us. no longer pushes to us.
""" """
assert digest
assert byte_data is not None
assert storage
try: try:
return ImageStorage.get(content_checksum=digest, uploading=False) return ImageStorage.get(content_checksum=digest, uploading=False)
except ImageStorage.DoesNotExist: except ImageStorage.DoesNotExist:

View file

@ -341,9 +341,6 @@ def set_image_metadata(docker_image_id, namespace_name, repository_name, created
# We cleanup any old checksum in case it's a retry after a fail # We cleanup any old checksum in case it's a retry after a fail
fetched.v1_checksum = None fetched.v1_checksum = None
fetched.storage.content_checksum = None
fetched.storage.save()
fetched.comment = comment fetched.comment = comment
fetched.command = command fetched.command = command
fetched.v1_json_metadata = v1_json_metadata fetched.v1_json_metadata = v1_json_metadata