Fix get_blob_path to not make any database calls and add a test

This will be supported by caching, hopefully removing the need to hit the database when the blob object is cached
This commit is contained in:
Joseph Schorr 2017-12-13 16:27:46 -05:00
parent e06a83faf9
commit 51e67ab7f5
4 changed files with 44 additions and 10 deletions

View file

@ -211,7 +211,8 @@ class PreOCIModel(DockerRegistryV2DataInterface):
uuid=blob_record.uuid,
digest=blob_digest,
size=blob_upload.byte_count,
locations=[blob_upload.location_name],)
locations=[blob_upload.location_name],
cas_path=blob_record.cas_path)
def lookup_blobs_by_digest(self, namespace_name, repo_name, digests):
def _blob_view(blob_record):
@ -219,6 +220,7 @@ class PreOCIModel(DockerRegistryV2DataInterface):
uuid=blob_record.uuid,
digest=blob_record.content_checksum,
size=blob_record.image_size,
cas_path=blob_record.cas_path,
locations=None, # Note: Locations is None in this case.
)
@ -235,7 +237,8 @@ class PreOCIModel(DockerRegistryV2DataInterface):
uuid=blob_record.uuid,
digest=digest,
size=blob_record.image_size,
locations=blob_record.locations,)
locations=blob_record.locations,
cas_path=blob_record.cas_path)
except model.BlobDoesNotExist:
return None
@ -254,8 +257,7 @@ class PreOCIModel(DockerRegistryV2DataInterface):
label.media_type)
def get_blob_path(self, blob):
blob_record = model.storage.get_storage_by_uuid(blob.uuid)
return model.storage.get_layer_path(blob_record)
return model.storage.get_layer_path_for_storage(blob.uuid, blob.cas_path, blob.digest)
def set_manifest_expires_after(self, namespace_name, repo_name, digest, expires_after_sec):
try: