Skip to content

Commit

Permalink
#342 Use transaction.atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
viliambalaz committed Jan 23, 2021
1 parent 96a0427 commit 8fd7fcb
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ def handle(self, *args, **options):
if not content:
raise CommandError(u'No content given.')

with transaction.atomic():
attachments_finalization.delete()
AttachmentFinalization.objects.create(
attachment=attachment,
successful=True,
file=ContentFile(content),
content_type=options[u'content_type'] or magic.from_buffer(content, mime=True),
debug=options[u'debug'],
)
attachments_finalization.delete()
AttachmentFinalization.objects.create(
attachment=attachment,
successful=True,
file=ContentFile(content),
content_type=options[u'content_type'] or magic.from_buffer(content, mime=True),
debug=options[u'debug'],
)

0 comments on commit 8fd7fcb

Please sign in to comment.