upload: Fix single attachments not being claimed on message edit.

Fixed an attachments not being claimed if just one new attachment is
added (aka the common case).
This commit is contained in:
rahuldeve 2016-07-25 01:33:22 +05:30 committed by Tim Abbott
parent e06d5fbec9
commit 5ed2b01bc7
2 changed files with 2 additions and 2 deletions

View File

@ -3368,5 +3368,5 @@ def check_attachment_reference_change(prev_content, message):
pass
to_add = list(new_attachments - prev_attachments)
if len(to_add) > 1:
if len(to_add) > 0:
do_claim_attachments(message)

View File

@ -230,7 +230,7 @@ class FileUploadTest(AuthedTestCase):
message = Message.objects.get(id=msg_id)
f1_attachment = Attachment.objects.get(path_id=f1_path_id)
f2_attachment = Attachment.objects.get(path_id=f2_path_id)
f3_attachment = Attachment.objects.get(path_id=f2_path_id)
f3_attachment = Attachment.objects.get(path_id=f3_path_id)
self.assertTrue(message not in f1_attachment.messages.all())
self.assertTrue(message in f2_attachment.messages.all())