Fix a bug in manifest backfill that made it only work on active tags

This commit is contained in:
Joseph Schorr 2019-01-21 16:42:24 -05:00
parent cb637e1233
commit 0035a1ec6d
3 changed files with 7 additions and 8 deletions

View file

@ -483,8 +483,8 @@ class PreOCIModel(SharedModel, RegistryDataInterface):
storage_map = {blob.content_checksum: blob.id for blob in blob_query}
try:
tag_manifest, _ = model.tag.associate_generated_tag_manifest(namespace_name, repo_name,
tag.name, manifest, storage_map)
tag_manifest, _ = model.tag.associate_generated_tag_manifest_with_tag(tag_obj, manifest,
storage_map)
assert tag_manifest
except IntegrityError:
tag_manifest = model.tag.get_tag_manifest(tag_obj)

View file

@ -435,14 +435,15 @@ def clear_rows(initialized_db):
])
def test_backfill_manifest_for_tag(repo_namespace, repo_name, clear_rows, pre_oci_model):
repository_ref = pre_oci_model.lookup_repository(repo_namespace, repo_name)
tags = pre_oci_model.list_repository_tags(repository_ref)
tags, has_more = pre_oci_model.list_repository_tag_history(repository_ref, size=2500)
assert tags
assert not has_more
for tag in tags:
assert not tag.manifest_digest
assert pre_oci_model.backfill_manifest_for_tag(tag)
tags = pre_oci_model.list_repository_tags(repository_ref, include_legacy_images=True)
tags, _ = pre_oci_model.list_repository_tag_history(repository_ref)
assert tags
for tag in tags:
assert tag.manifest_digest