Leave attachment insert early if there are no attachments.

This commit is contained in:
Greyson Parrelli
2023-11-08 09:44:13 -05:00
committed by Cody Henthorne
parent 5cd2568776
commit 29c70acf4e
2 changed files with 8 additions and 4 deletions

View File

@@ -847,6 +847,10 @@ public class AttachmentTable extends DatabaseTable {
@NonNull Map<Attachment, AttachmentId> insertAttachmentsForMessage(long mmsId, @NonNull List<Attachment> attachments, @NonNull List<Attachment> quoteAttachment)
throws MmsException
{
if (attachments.isEmpty() && quoteAttachment.isEmpty()) {
return Collections.emptyMap();
}
Log.d(TAG, "insertParts(" + attachments.size() + ")");
Map<Attachment, AttachmentId> insertedAttachments = new HashMap<>();

View File

@@ -2975,7 +2975,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
val messageId = db.insert(TABLE_NAME, null, contentValues)
if (messageId < 0) {
Log.w(TAG, "Tried to insert media message but failed. Assuming duplicate.")
return@withinTransaction kotlin.Pair(-1L, null)
return@withinTransaction -1L to null
}
threads.markAsActiveEarly(threadId)
@@ -3009,11 +3009,11 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
}
}
kotlin.Pair(messageId, insertedAttachments)
messageId to insertedAttachments
}
if (messageId < 0) {
return kotlin.Pair(messageId, insertedAttachments)
return messageId to insertedAttachments
}
insertListener?.onComplete()
@@ -3025,7 +3025,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
threads.update(threadId, unarchive)
}
return kotlin.Pair(messageId, insertedAttachments)
return messageId to insertedAttachments
}
/**