Skip to content

Commit fce33cd

Browse files
committed
Don't crash if an attachment has been created already, just reuse it - this case shouldn't actually happen, but apparently sometimes does, probably due to a concurrency issue
- Legacy-Id: 5797
1 parent f75100b commit fce33cd

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

ietf/liaisons/formsREDESIGN.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,13 @@ def save_attachments(self, instance):
280280
extension = ''
281281
written += 1
282282
name = instance.name() + ("-attachment-%s" % written)
283-
attach = Document.objects.create(
284-
title = self.data.get(title_key),
285-
type_id = "liaison",
283+
attach, _ = Document.objects.get_or_create(
286284
name = name,
287-
external_url = name + extension, # strictly speaking not necessary, but just for the time being ...
285+
defaults=dict(
286+
title = self.data.get(title_key),
287+
type_id = "liaison",
288+
external_url = name + extension, # strictly speaking not necessary, but just for the time being ...
289+
)
288290
)
289291
instance.attachments.add(attach)
290292
attach_file = open(os.path.join(settings.LIAISON_ATTACH_PATH, attach.name + extension), 'w')

0 commit comments

Comments
 (0)