Merge remote-tracking branch 'origin/master' into rustedbuilds
This commit is contained in:
commit
de49ce151b
14 changed files with 124 additions and 50 deletions
|
@ -888,16 +888,20 @@ def create_repository(namespace, name, creating_user, visibility='private'):
|
|||
return repo
|
||||
|
||||
|
||||
def __translate_ancestry(old_ancestry, translations, existing_images):
|
||||
def __translate_ancestry(old_ancestry, translations, repository, username):
|
||||
if old_ancestry == '/':
|
||||
return '/'
|
||||
|
||||
def translate_id(old_id):
|
||||
logger.debug('Translating id: %s', old_id)
|
||||
if old_id not in translations:
|
||||
# Figure out which docker_image_id the old id refers to, then find a
|
||||
# a local one
|
||||
old = Image.select(Image.docker_image_id).where(Image.id == old_id).get()
|
||||
translations[old_id] = existing_images[old.docker_image_id]
|
||||
image_in_repo = find_create_or_link_image(old.docker_image_id,
|
||||
repository, username,
|
||||
translations)
|
||||
translations[old_id] = image_in_repo.id
|
||||
|
||||
return translations[old_id]
|
||||
|
||||
|
@ -906,9 +910,14 @@ def __translate_ancestry(old_ancestry, translations, existing_images):
|
|||
return '/%s/' % '/'.join(new_ids)
|
||||
|
||||
|
||||
def create_or_link_image(docker_image_id, repository, username, translations,
|
||||
existing_images):
|
||||
def find_create_or_link_image(docker_image_id, repository, username,
|
||||
translations):
|
||||
with transaction_factory(db):
|
||||
repo_image = get_repo_image(repository.namespace, repository.name,
|
||||
docker_image_id)
|
||||
if repo_image:
|
||||
return repo_image
|
||||
|
||||
query = (Image
|
||||
.select(Image, ImageStorage)
|
||||
.distinct()
|
||||
|
@ -930,7 +939,8 @@ def create_or_link_image(docker_image_id, repository, username, translations,
|
|||
logger.debug(msg, docker_image_id, to_copy.storage.uuid)
|
||||
|
||||
new_image_ancestry = __translate_ancestry(to_copy.ancestors,
|
||||
translations, existing_images)
|
||||
translations, repository,
|
||||
username)
|
||||
|
||||
storage = to_copy.storage
|
||||
origin_image_id = to_copy.id
|
||||
|
@ -943,6 +953,7 @@ def create_or_link_image(docker_image_id, repository, username, translations,
|
|||
ancestors=new_image_ancestry)
|
||||
|
||||
if origin_image_id:
|
||||
logger.debug('Storing translation %s -> %s', origin_image_id, new_image.id)
|
||||
translations[origin_image_id] = new_image.id
|
||||
|
||||
return new_image
|
||||
|
|
Reference in a new issue