diff options
-rw-r--r-- | patchwork/parser.py | 7 | ||||
-rw-r--r-- | patchwork/tests/test_parser.py | 1 |
2 files changed, 4 insertions, 4 deletions
diff --git a/patchwork/parser.py b/patchwork/parser.py index dce03a4..021c034 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -1069,7 +1069,10 @@ def parse_mail(mail, list_id=None): filenames = find_filenames(diff) delegate = find_delegate_by_filename(project, filenames) - try: + with transaction.atomic(): + if Patch.objects.filter(project=project, msgid=msgid): + raise DuplicateMailError(msgid=msgid) + patch = Patch.objects.create( msgid=msgid, project=project, @@ -1084,8 +1087,6 @@ def parse_mail(mail, list_id=None): delegate=delegate, state=find_state(mail)) logger.debug('Patch saved') - except IntegrityError: - raise DuplicateMailError(msgid=msgid) for attempt in range(1, 11): # arbitrary retry count try: diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py index 0122fb8..b640a3a 100644 --- a/patchwork/tests/test_parser.py +++ b/patchwork/tests/test_parser.py @@ -1138,7 +1138,6 @@ class DuplicateMailTest(TestCase): self.assertEqual(errors, []) - @unittest.expectedFailure def test_duplicate_patch(self): diff = read_patch('0001-add-line.patch') m = create_email(diff, listid=self.listid, msgid='1@example.com') |