Skip to content

Commit

Permalink
Fix cross-domain content assertion
Browse files Browse the repository at this point in the history
(cherry picked from commit c1d6081)
  • Loading branch information
gerrod3 authored and patchback[bot] committed Nov 11, 2024
1 parent 71ae0d2 commit da3322a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/content-assert.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an assertion on all content being added/removed in a repository version is of the same domain.
12 changes: 10 additions & 2 deletions pulpcore/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,11 @@ def add_content(self, content):
if self.complete:
raise ResourceImmutableError(self)

assert not content.exclude(pulp_domain_id=get_domain_pk()).exists()
assert (
not Content.objects.filter(pk__in=content)
.exclude(pulp_domain_id=get_domain_pk())
.exists()
)
repo_content = []
to_add = set(content.values_list("pk", flat=True)) - set(
self.content.values_list("pk", flat=True)
Expand Down Expand Up @@ -1026,7 +1030,11 @@ def remove_content(self, content):

if not content or not content.count():
return
assert not content.exclude(pulp_domain_id=get_domain_pk()).exists()
assert (
not Content.objects.filter(pk__in=content)
.exclude(pulp_domain_id=get_domain_pk())
.exists()
)

# Normalize representation if content has already been added in this version.
# Undo addition by deleting the RepositoryContent.
Expand Down

0 comments on commit da3322a

Please sign in to comment.