Read blobs from new manifest blob table where relevant
This commit is contained in:
parent
4985040d31
commit
adccdd30ca
9 changed files with 146 additions and 62 deletions
|
@ -270,7 +270,7 @@ def get_layer_path_for_storage(storage_uuid, cas_path, content_checksum):
|
|||
return store.blob_path(content_checksum)
|
||||
|
||||
|
||||
def lookup_repo_storages_by_content_checksum(repo, checksums):
|
||||
def lookup_repo_storages_by_content_checksum(repo, checksums, by_manifest=False):
|
||||
""" Looks up repository storages (without placements) matching the given repository
|
||||
and checksum. """
|
||||
# There may be many duplicates of the checksums, so for performance reasons we are going
|
||||
|
@ -279,14 +279,29 @@ def lookup_repo_storages_by_content_checksum(repo, checksums):
|
|||
|
||||
for counter, checksum in enumerate(set(checksums)):
|
||||
query_alias = 'q{0}'.format(counter)
|
||||
candidate_subq = (ImageStorage
|
||||
.select(ImageStorage.id, ImageStorage.content_checksum,
|
||||
ImageStorage.image_size, ImageStorage.uuid, ImageStorage.cas_path,
|
||||
ImageStorage.uncompressed_size, ImageStorage.uploading)
|
||||
.join(Image)
|
||||
.where(Image.repository == repo, ImageStorage.content_checksum == checksum)
|
||||
.limit(1)
|
||||
.alias(query_alias))
|
||||
|
||||
# TODO(jschorr): Remove once we have a new-style model for tracking temp uploaded blobs and
|
||||
# all legacy tables have been removed.
|
||||
if by_manifest:
|
||||
candidate_subq = (ImageStorage
|
||||
.select(ImageStorage.id, ImageStorage.content_checksum,
|
||||
ImageStorage.image_size, ImageStorage.uuid, ImageStorage.cas_path,
|
||||
ImageStorage.uncompressed_size, ImageStorage.uploading)
|
||||
.join(ManifestBlob)
|
||||
.where(ManifestBlob.repository == repo,
|
||||
ImageStorage.content_checksum == checksum)
|
||||
.limit(1)
|
||||
.alias(query_alias))
|
||||
else:
|
||||
candidate_subq = (ImageStorage
|
||||
.select(ImageStorage.id, ImageStorage.content_checksum,
|
||||
ImageStorage.image_size, ImageStorage.uuid, ImageStorage.cas_path,
|
||||
ImageStorage.uncompressed_size, ImageStorage.uploading)
|
||||
.join(Image)
|
||||
.where(Image.repository == repo, ImageStorage.content_checksum == checksum)
|
||||
.limit(1)
|
||||
.alias(query_alias))
|
||||
|
||||
queries.append(ImageStorage
|
||||
.select(SQL('*'))
|
||||
.from_(candidate_subq))
|
||||
|
|
Reference in a new issue