summaryrefslogtreecommitdiff
path: root/patchwork/parser.py
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2020-04-16 09:29:27 +0800
committerStephen Finucane <stephen@that.guru>2020-04-18 12:30:39 +0100
commit55aa9cd749f3ff0de430c8f04c687d691c3a703a (patch)
tree8ed3d53f91f5c6802003e23dc9d8ed5144dba665 /patchwork/parser.py
parent947c6aae94b7b554ca701c1d7e5baf000759ed2d (diff)
downloadpatchwork-55aa9cd749f3ff0de430c8f04c687d691c3a703a.tar
patchwork-55aa9cd749f3ff0de430c8f04c687d691c3a703a.tar.gz
parser: don't trigger database IntegrityErrors on duplicate comments
As we've done for the Patch model, this change prevents database errors from duplicate Comments. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Stephen Finucane <stephen@that.guru>
Diffstat (limited to 'patchwork/parser.py')
-rw-r--r--patchwork/parser.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/patchwork/parser.py b/patchwork/parser.py
index 021c034..215f48c 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -1254,7 +1254,9 @@ def parse_mail(mail, list_id=None):
author = get_or_create_author(mail, project)
- try:
+ with transaction.atomic():
+ if Comment.objects.filter(submission=submission, msgid=msgid):
+ raise DuplicateMailError(msgid=msgid)
comment = Comment.objects.create(
submission=submission,
msgid=msgid,
@@ -1262,8 +1264,6 @@ def parse_mail(mail, list_id=None):
headers=headers,
submitter=author,
content=message)
- except IntegrityError:
- raise DuplicateMailError(msgid=msgid)
logger.debug('Comment saved')