Skip to content

Commit 4e1a457

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>
1 parent dea04fa commit 4e1a457

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
@@ -1223,10 +1223,6 @@ def remove_content(self, content):
12231223
content_ids = set(self.content_ids)
12241224
to_remove = set(content.values_list("pk", flat=True))
12251225
with transaction.atomic():
1226-
if to_remove:
1227-
self.content_ids = list(content_ids - to_remove)
1228-
self.save()
1229-
12301226
# Normalize representation if content has already been added in this version.
12311227
# Undo addition by deleting the RepositoryContent.
12321228
RepositoryContent.objects.filter(
@@ -1241,6 +1237,10 @@ def remove_content(self, content):
12411237
)
12421238
q_set.update(version_removed=self)
12431239

1240+
if to_remove:
1241+
self.content_ids = list(content_ids - to_remove)
1242+
self.save()
1243+
12441244
def set_content(self, content):
12451245
"""
12461246
Sets the repo version content by calling remove_content() then add_content().

0 commit comments

Comments
 (0)