Merge pull request #154 from coreos-inc/optimize

Optimize the generate_headers check to skip the permissions load when we don't need it
This commit is contained in:
Jimmy Zelinskie 2015-06-19 14:04:46 -04:00
commit d5e4b35a78

View file

@ -55,10 +55,10 @@ def generate_headers(scope=GrantType.READ_REPOSITORY, add_grant_for_status=None)
grants = []
if scope == GrantType.READ_REPOSITORY:
if ReadRepositoryPermission(namespace, repository).can() or force_grant:
if force_grant or ReadRepositoryPermission(namespace, repository).can():
grants.append(repository_read_grant(namespace, repository))
elif scope == GrantType.WRITE_REPOSITORY:
if ModifyRepositoryPermission(namespace, repository).can() or force_grant:
if force_grant or ModifyRepositoryPermission(namespace, repository).can():
grants.append(repository_write_grant(namespace, repository))
# Generate a signed token for the user (if any) and the grants (if any)