forked from upstream-mirrors/quik
#1332 - Don't allow bad message to break restore, send log when messages fail to restore
This commit is contained in:
@@ -176,6 +176,7 @@ class BackupRepositoryImpl @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val messageCount = backup?.messages?.size ?: 0
|
val messageCount = backup?.messages?.size ?: 0
|
||||||
|
var errorCount = 0
|
||||||
|
|
||||||
backup?.messages?.forEachIndexed { index, message ->
|
backup?.messages?.forEachIndexed { index, message ->
|
||||||
if (stopFlag) {
|
if (stopFlag) {
|
||||||
@@ -187,7 +188,8 @@ class BackupRepositoryImpl @Inject constructor(
|
|||||||
// Update the progress
|
// Update the progress
|
||||||
restoreProgress.onNext(BackupRepository.Progress.Running(messageCount, index))
|
restoreProgress.onNext(BackupRepository.Progress.Running(messageCount, index))
|
||||||
|
|
||||||
context.contentResolver.insert(Telephony.Sms.CONTENT_URI, contentValuesOf(
|
try {
|
||||||
|
context.contentResolver.insert(Telephony.Sms.CONTENT_URI, contentValuesOf(
|
||||||
Telephony.Sms.TYPE to message.type,
|
Telephony.Sms.TYPE to message.type,
|
||||||
Telephony.Sms.ADDRESS to message.address,
|
Telephony.Sms.ADDRESS to message.address,
|
||||||
Telephony.Sms.DATE to message.date,
|
Telephony.Sms.DATE to message.date,
|
||||||
@@ -200,6 +202,14 @@ class BackupRepositoryImpl @Inject constructor(
|
|||||||
Telephony.Sms.SERVICE_CENTER to message.serviceCenter,
|
Telephony.Sms.SERVICE_CENTER to message.serviceCenter,
|
||||||
Telephony.Sms.LOCKED to message.locked,
|
Telephony.Sms.LOCKED to message.locked,
|
||||||
Telephony.Sms.SUBSCRIPTION_ID to message.subId))
|
Telephony.Sms.SUBSCRIPTION_ID to message.subId))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Timber.w(e)
|
||||||
|
errorCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorCount > 0) {
|
||||||
|
Timber.w(Exception("Failed to backup $errorCount/$messageCount messages"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync the messages
|
// Sync the messages
|
||||||
|
|||||||
Reference in New Issue
Block a user