Skip to content

Instantly share code, notes, and snippets.

@bmbouter
Created November 5, 2019 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmbouter/0897648ce254faecbea730159f4e9cd1 to your computer and use it in GitHub Desktop.
Save bmbouter/0897648ce254faecbea730159f4e9cd1 to your computer and use it in GitHub Desktop.
diff --git a/pulpcore/app/tasks/repository.py b/pulpcore/app/tasks/repository.py
index 1e9953dfc..25f787b9a 100644
--- a/pulpcore/app/tasks/repository.py
+++ b/pulpcore/app/tasks/repository.py
@@ -66,7 +66,8 @@ def delete_version(pk):
version.delete()
-def add_and_remove(repository_pk, add_content_units, remove_content_units, base_version_pk=None):
+def add_and_remove(repository_pk, add_content_units, remove_content_units, base_version_pk=None,
+ plugin_context_manager=None):
"""
Create a new repository version by adding and then removing content units.
@@ -95,5 +96,10 @@ def add_and_remove(repository_pk, add_content_units, remove_content_units, base_
remove_content_units = []
with repository.new_version(base_version=base_version) as new_version:
- new_version.remove_content(models.Content.objects.filter(pk__in=remove_content_units))
- new_version.add_content(models.Content.objects.filter(pk__in=add_content_units))
+ if plugin_context_manager:
+ with plugin_context_manager:
+ new_version.remove_content(models.Content.objects.filter(pk__in=remove_content_units))
+ new_version.add_content(models.Content.objects.filter(pk__in=add_content_units))
+ else:
+ new_version.remove_content(models.Content.objects.filter(pk__in=remove_content_units))
+ new_version.add_content(models.Content.objects.filter(pk__in=add_content_units))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment