Add an extra check in garbage collection to ensure we don't delete manifests referenced by other new-style tags

This commit is contained in:
Joseph Schorr 2018-11-02 15:56:18 -04:00
parent d0e1f464ff
commit 5b089653d1

View file

@ -438,6 +438,15 @@ def _delete_tags(repo, query_modifier=None):
still_referenced_manifests = set([tmt.manifest_id for tmt in ref_query])
manifest_ids_to_delete = list(manifest_ids_to_delete - still_referenced_manifests)
# Filter out any manifests referenced by other tags.
if manifest_ids_to_delete:
ref_query = (Tag
.select()
.where(Tag.manifest << manifest_ids_to_delete))
still_referenced_manifests = set([t.manifest_id for t in ref_query])
manifest_ids_to_delete = list(set(manifest_ids_to_delete) - still_referenced_manifests)
num_deleted_manifests = 0
if len(tag_manifest_ids_to_delete) > 0:
# Find the set of IDs for all the labels to delete.