Merge pull request #3407 from quay/fix-npe-in-tag-expiration

Fix NPE when setting tag to not expire
This commit is contained in:
Joseph Schorr 2019-03-11 13:04:02 -04:00 committed by GitHub
commit 21028ab3fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -421,7 +421,7 @@ def set_tag_end_ms(tag, end_ms):
.where(TagToRepositoryTag.tag == tag) .where(TagToRepositoryTag.tag == tag)
.get()).repository_tag .get()).repository_tag
old_style_tag.lifetime_end_ts = end_ms / 1000 old_style_tag.lifetime_end_ts = end_ms / 1000 if end_ms is not None else None
old_style_tag.save() old_style_tag.save()
except TagToRepositoryTag.DoesNotExist: except TagToRepositoryTag.DoesNotExist:
pass pass

View file

@ -214,6 +214,13 @@ def test_change_tag_expiration(timedelta, expected_timedelta, initialized_db):
expected_ms = (updated_tag.lifetime_start_ms + offset) expected_ms = (updated_tag.lifetime_start_ms + offset)
assert updated_tag.lifetime_end_ms == expected_ms assert updated_tag.lifetime_end_ms == expected_ms
original_end_ms, okay = change_tag_expiration(tag, None)
assert okay
assert original_end_ms == expected_ms
updated_tag = Tag.get(id=tag.id)
assert updated_tag.lifetime_end_ms is None
def test_set_tag_expiration_for_manifest(initialized_db): def test_set_tag_expiration_for_manifest(initialized_db):
tag = Tag.get() tag = Tag.get()