Skip to content

Commit ea53f1b

Browse files
git-hyagiclaude
authored andcommitted
Fix RepositoryVersion.remove_content using wrong queryset for lazy content
The remove_content method was incorrectly using the unfiltered `content` queryset instead of `to_remove` when deleting or marking RepositoryContent entries as removed. This caused all content to be removed from the repository version rather than only the specified lazy content. Fixes: #7851 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> (cherry picked from commit 4e1a457)
1 parent b95e5da commit ea53f1b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

CHANGES/7851.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed `RepositoryVersion.remove_content` failing when the queryset is derived from `self.content` and the repository version contains >= 65,535 content items. The lazy queryset was re-evaluated after `content_ids` was already updated, causing `RepositoryContent` entries to be left orphaned.

pulpcore/app/models/repository.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,10 +1147,6 @@ def remove_content(self, content):
11471147
content_ids = set(self._get_content_ids())
11481148
to_remove = set(content.values_list("pk", flat=True))
11491149
with transaction.atomic():
1150-
if to_remove:
1151-
self.content_ids = list(content_ids - to_remove)
1152-
self.save()
1153-
11541150
# Normalize representation if content has already been added in this version.
11551151
# Undo addition by deleting the RepositoryContent.
11561152
RepositoryContent.objects.filter(
@@ -1165,6 +1161,10 @@ def remove_content(self, content):
11651161
)
11661162
q_set.update(version_removed=self)
11671163

1164+
if to_remove:
1165+
self.content_ids = list(content_ids - to_remove)
1166+
self.save()
1167+
11681168
def set_content(self, content):
11691169
"""
11701170
Sets the repo version content by calling remove_content() then add_content().

0 commit comments

Comments
 (0)