Improve the performance of fetching manifest blobs by checksum.
This commit is contained in:
parent
790a33589d
commit
b564492ea7
2 changed files with 23 additions and 10 deletions
|
@ -287,16 +287,16 @@ def _write_manifest(namespace, repo_name, manifest):
|
|||
# know which V1 images we need to synthesize and which ones are invalid.
|
||||
layers = list(manifest.layers)
|
||||
|
||||
docker_image_ids = [mdata.v1_metadata.docker_id for mdata in layers]
|
||||
parent_image_ids = [mdata.v1_metadata.parent for mdata in layers
|
||||
if mdata.v1_metadata.parent]
|
||||
all_image_ids = list(set(docker_image_ids + parent_image_ids))
|
||||
docker_image_ids = {mdata.v1_metadata.docker_id for mdata in layers}
|
||||
parent_image_ids = {mdata.v1_metadata.parent for mdata in layers
|
||||
if mdata.v1_metadata.parent}
|
||||
all_image_ids = list(docker_image_ids | parent_image_ids)
|
||||
|
||||
images_query = model.image.lookup_repository_images(repo, all_image_ids)
|
||||
images_map = {image.docker_image_id: image for image in images_query}
|
||||
|
||||
# Lookup the storages associated with each blob in the manifest.
|
||||
checksums = [str(mdata.digest) for mdata in manifest.layers]
|
||||
checksums = list({str(mdata.digest) for mdata in manifest.layers})
|
||||
storage_query = model.storage.lookup_repo_storages_by_content_checksum(repo, checksums)
|
||||
storage_map = {storage.content_checksum: storage for storage in storage_query}
|
||||
|
||||
|
|
Reference in a new issue