Add some structured logging for backup import skips.
This commit is contained in:
parent
577b445bf8
commit
6928c22477
2 changed files with 30 additions and 4 deletions
|
@ -114,3 +114,28 @@ object ExportOddities {
|
||||||
return "[ODDITY][$sentTimestamp] $message"
|
return "[ODDITY][$sentTimestamp] $message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These represent situations where we will skip importing a data frame due to the data being invalid.
|
||||||
|
*/
|
||||||
|
object ImportSkips {
|
||||||
|
fun fromRecipientNotFound(sentTimestamp: Long): String {
|
||||||
|
return log(sentTimestamp, "Failed to find the fromRecipient for the message.")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun chatIdLocalRecipientNotFound(sentTimestamp: Long, chatId: Long): String {
|
||||||
|
return log(sentTimestamp, "Failed to find a local recipientId for the provided chatId. ChatId in backup: $chatId")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun chatIdRemoteRecipientNotFound(sentTimestamp: Long, chatId: Long): String {
|
||||||
|
return log(sentTimestamp, "Failed to find a remote recipientId for the provided chatId. ChatId in backup: $chatId")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun chatIdThreadNotFound(sentTimestamp: Long, chatId: Long): String {
|
||||||
|
return log(sentTimestamp, "Failed to find a threadId for the provided chatId. ChatId in backup: $chatId")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun log(sentTimestamp: Long, message: String): String {
|
||||||
|
return "[SKIP][$sentTimestamp] $message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.signal.core.util.update
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment
|
import org.thoughtcrime.securesms.attachments.Attachment
|
||||||
import org.thoughtcrime.securesms.attachments.PointerAttachment
|
import org.thoughtcrime.securesms.attachments.PointerAttachment
|
||||||
import org.thoughtcrime.securesms.attachments.TombstoneAttachment
|
import org.thoughtcrime.securesms.attachments.TombstoneAttachment
|
||||||
|
import org.thoughtcrime.securesms.backup.v2.ImportSkips
|
||||||
import org.thoughtcrime.securesms.backup.v2.ImportState
|
import org.thoughtcrime.securesms.backup.v2.ImportState
|
||||||
import org.thoughtcrime.securesms.backup.v2.proto.BodyRange
|
import org.thoughtcrime.securesms.backup.v2.proto.BodyRange
|
||||||
import org.thoughtcrime.securesms.backup.v2.proto.ChatItem
|
import org.thoughtcrime.securesms.backup.v2.proto.ChatItem
|
||||||
|
@ -158,25 +159,25 @@ class ChatItemArchiveImporter(
|
||||||
fun import(chatItem: ChatItem) {
|
fun import(chatItem: ChatItem) {
|
||||||
val fromLocalRecipientId: RecipientId? = importState.remoteToLocalRecipientId[chatItem.authorId]
|
val fromLocalRecipientId: RecipientId? = importState.remoteToLocalRecipientId[chatItem.authorId]
|
||||||
if (fromLocalRecipientId == null) {
|
if (fromLocalRecipientId == null) {
|
||||||
Log.w(TAG, "[insert] Could not find a local recipient for backup recipient ID ${chatItem.authorId}! Skipping.")
|
Log.w(TAG, ImportSkips.fromRecipientNotFound(chatItem.dateSent))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val chatLocalRecipientId: RecipientId? = importState.chatIdToLocalRecipientId[chatItem.chatId]
|
val chatLocalRecipientId: RecipientId? = importState.chatIdToLocalRecipientId[chatItem.chatId]
|
||||||
if (chatLocalRecipientId == null) {
|
if (chatLocalRecipientId == null) {
|
||||||
Log.w(TAG, "[insert] Could not find a local recipient for chatId ${chatItem.chatId}! Skipping.")
|
Log.w(TAG, ImportSkips.chatIdLocalRecipientNotFound(chatItem.dateSent, chatItem.chatId))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val localThreadId: Long? = importState.chatIdToLocalThreadId[chatItem.chatId]
|
val localThreadId: Long? = importState.chatIdToLocalThreadId[chatItem.chatId]
|
||||||
if (localThreadId == null) {
|
if (localThreadId == null) {
|
||||||
Log.w(TAG, "[insert] Could not find a local threadId for backup chatId ${chatItem.chatId}! Skipping.")
|
Log.w(TAG, ImportSkips.chatIdThreadNotFound(chatItem.dateSent, chatItem.chatId))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val chatBackupRecipientId: Long? = importState.chatIdToBackupRecipientId[chatItem.chatId]
|
val chatBackupRecipientId: Long? = importState.chatIdToBackupRecipientId[chatItem.chatId]
|
||||||
if (chatBackupRecipientId == null) {
|
if (chatBackupRecipientId == null) {
|
||||||
Log.w(TAG, "[insert] Could not find a backup recipientId for backup chatId ${chatItem.chatId}! Skipping.")
|
Log.w(TAG, ImportSkips.chatIdRemoteRecipientNotFound(chatItem.dateSent, chatItem.chatId))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val messageInsert = chatItem.toMessageInsert(fromLocalRecipientId, chatLocalRecipientId, localThreadId)
|
val messageInsert = chatItem.toMessageInsert(fromLocalRecipientId, chatLocalRecipientId, localThreadId)
|
||||||
|
|
Loading…
Add table
Reference in a new issue