Fix off-by-one error in repo tags pagination

Fixes #1665
This commit is contained in:
Joseph Schorr 2016-08-02 14:17:33 -04:00
parent c3a401d960
commit b1b0da7afd
3 changed files with 50 additions and 16 deletions

View file

@ -47,17 +47,13 @@ class ListRepositoryTags(RepositoryParamResource):
page = max(1, parsed_args.get('page', 1))
limit = min(100, max(1, parsed_args.get('limit', 50)))
tags, has_additional = model.tag.list_repository_tag_history(repo, page=page, size=limit,
specific_tag=specific_tag)
# Note: We ask for limit+1 here, so we can check to see if there are
# additional pages of results.
tags = model.tag.list_repository_tag_history(repo, page=page, size=limit+1,
specific_tag=specific_tag)
tags = list(tags)
return {
'tags': [tag_view(tag) for tag in tags[0:limit]],
'tags': [tag_view(tag) for tag in tags],
'page': page,
'has_additional': len(tags) >= limit
'has_additional': has_additional,
}