Use a cache for ImageStorageLocation

No need to reload it from the DB or join as it is a static set only changed during migration
This commit is contained in:
Joseph Schorr 2016-06-02 15:57:59 -04:00
parent ec492bb683
commit 7aa6b812e2
2 changed files with 40 additions and 22 deletions

View file

@ -2,8 +2,8 @@ from uuid import uuid4
from data.model import (tag, _basequery, BlobDoesNotExist, InvalidBlobUpload, db_transaction,
storage as storage_model, InvalidImageException)
from data.database import (Repository, Namespace, ImageStorage, Image, ImageStorageLocation,
ImageStoragePlacement, BlobUpload)
from data.database import (Repository, Namespace, ImageStorage, Image, ImageStoragePlacement,
BlobUpload)
def get_repo_blob_by_digest(namespace, repo_name, blob_digest):
@ -75,6 +75,6 @@ def get_blob_upload(namespace, repo_name, upload_uuid):
def initiate_upload(namespace, repo_name, uuid, location_name, storage_metadata):
repo = _basequery.get_existing_repository(namespace, repo_name)
location = ImageStorageLocation.get(name=location_name)
return BlobUpload.create(repository=repo, location=location, uuid=uuid,
location = storage_model.get_image_location_for_name(location_name)
return BlobUpload.create(repository=repo, location=location.id, uuid=uuid,
storage_metadata=storage_metadata)