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:
parent
e06a83faf9
commit
51e67ab7f5
4 changed files with 44 additions and 10 deletions
|
@ -248,12 +248,19 @@ def get_storage_by_uuid(storage_uuid):
|
|||
|
||||
def get_layer_path(storage_record):
|
||||
""" Returns the path in the storage engine to the layer data referenced by the storage row. """
|
||||
store = config.store
|
||||
if not storage_record.cas_path:
|
||||
logger.debug('Serving layer from legacy v1 path')
|
||||
return store.v1_image_layer_path(storage_record.uuid)
|
||||
return get_layer_path_for_storage(storage_record.uuid, storage_record.cas_path,
|
||||
storage_record.content_checksum)
|
||||
|
||||
return store.blob_path(storage_record.content_checksum)
|
||||
|
||||
def get_layer_path_for_storage(storage_uuid, cas_path, content_checksum):
|
||||
""" Returns the path in the storage engine to the layer data referenced by the storage
|
||||
information. """
|
||||
store = config.store
|
||||
if not cas_path:
|
||||
logger.debug('Serving layer from legacy v1 path for storage %s', storage_uuid)
|
||||
return store.v1_image_layer_path(storage_uuid)
|
||||
|
||||
return store.blob_path(content_checksum)
|
||||
|
||||
|
||||
def lookup_repo_storages_by_content_checksum(repo, checksums):
|
||||
|
|
Reference in a new issue