Skip to content

Commit

Permalink
Check collection name conflict with multi-content repo (#1897)
Browse files Browse the repository at this point in the history
(cherry picked from commit efc6f3f)
  • Loading branch information
awcrosby authored Jun 6, 2019
1 parent 304a3a2 commit 99c2b77
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions galaxy/api/v2/views/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def post(self, request, *args, **kwargs):
namespace = self._get_namespace(data)
self._check_namespace_access(namespace, request.user)
self._check_role_name_conflict(namespace, filename.name)
self._check_multi_repo_name_conflict(namespace, filename.name)
self._check_version_conflict(namespace, filename)
self._check_is_tarfile(request.data['file'].file.name)

Expand Down Expand Up @@ -165,6 +166,22 @@ def _check_role_name_conflict(self, ns, name):
'or rename the role via the meta/main.yml role_name attribute'
)

def _check_multi_repo_name_conflict(self, ns, name):
multi_content_repos = models.Repository.objects.filter(
format='multi',
provider_namespace__namespace=ns,
name__iexact=name,
)
if not multi_content_repos:
return
raise RepositoryNameError(
f'A multi-content repo ({ns.name}.{name}) under the '
f'namespace {ns.name} already exists. '
'Multi-content repos are deprecated in favor of collections. '
'You can delete the multi-content repo and '
're-import the collection.'
)

def _check_version_conflict(self, namespace, filename):
"""Validate that uploaded collection version does not exist."""
try:
Expand Down

0 comments on commit 99c2b77

Please sign in to comment.