Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Created March 19, 2021 20:25
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 daviddavis/3716ff3a988be8a5d797da136c7b90bf to your computer and use it in GitHub Desktop.
Save daviddavis/3716ff3a988be8a5d797da136c7b90bf to your computer and use it in GitHub Desktop.
diff --git a/pulpcore/plugin/stages/content_stages.py b/pulpcore/plugin/stages/content_stages.py
index 27771c75f..52bd9d823 100644
--- a/pulpcore/plugin/stages/content_stages.py
+++ b/pulpcore/plugin/stages/content_stages.py
@@ -1,5 +1,6 @@
from collections import defaultdict
+from django.core.exceptions import ObjectDoesNotExist
from django.db import IntegrityError, transaction
from django.db.models import Q
@@ -100,10 +101,13 @@ class ContentSaver(Stage):
try:
with transaction.atomic():
d_content.content.save()
- except IntegrityError:
- d_content.content = d_content.content.__class__.objects.get(
- d_content.content.q()
- )
+ except IntegrityError as e:
+ try:
+ d_content.content = d_content.content.__class__.objects.get(
+ d_content.content.q()
+ )
+ except ObjectDoesNotExist:
+ raise e
continue
for d_artifact in d_content.d_artifacts:
if not d_artifact.artifact._state.adding:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment