Various backup/restore bug fixes.
This commit is contained in:
parent
c622b7fdb1
commit
3184368fa7
4 changed files with 14 additions and 13 deletions
|
@ -31,11 +31,17 @@ fun CallLinkTable.getCallLinksForBackup(): BackupCallLinkIterator {
|
||||||
return BackupCallLinkIterator(cursor)
|
return BackupCallLinkIterator(cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CallLinkTable.restoreFromBackup(callLink: CallLink): RecipientId {
|
fun CallLinkTable.restoreFromBackup(callLink: CallLink): RecipientId? {
|
||||||
|
val rootKey: CallLinkRootKey
|
||||||
|
try {
|
||||||
|
rootKey = CallLinkRootKey(callLink.rootKey.toByteArray())
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
return SignalDatabase.callLinks.insertCallLink(
|
return SignalDatabase.callLinks.insertCallLink(
|
||||||
CallLinkTable.CallLink(
|
CallLinkTable.CallLink(
|
||||||
recipientId = RecipientId.UNKNOWN,
|
recipientId = RecipientId.UNKNOWN,
|
||||||
roomId = CallLinkRoomId.fromCallLinkRootKey(CallLinkRootKey(callLink.rootKey.toByteArray())),
|
roomId = CallLinkRoomId.fromCallLinkRootKey(rootKey),
|
||||||
credentials = CallLinkCredentials(callLink.rootKey.toByteArray(), callLink.adminKey?.toByteArray()),
|
credentials = CallLinkCredentials(callLink.rootKey.toByteArray(), callLink.adminKey?.toByteArray()),
|
||||||
state = SignalCallLinkState(
|
state = SignalCallLinkState(
|
||||||
name = callLink.name,
|
name = callLink.name,
|
||||||
|
@ -67,7 +73,9 @@ class BackupCallLinkIterator(private val cursor: Cursor) : Iterator<BackupRecipi
|
||||||
rootKey = callLink.credentials?.linkKeyBytes?.toByteString() ?: ByteString.EMPTY,
|
rootKey = callLink.credentials?.linkKeyBytes?.toByteString() ?: ByteString.EMPTY,
|
||||||
adminKey = callLink.credentials?.adminPassBytes?.toByteString(),
|
adminKey = callLink.credentials?.adminPassBytes?.toByteString(),
|
||||||
name = callLink.state.name,
|
name = callLink.state.name,
|
||||||
expirationMs = callLink.state.expiration.toEpochMilli(),
|
expirationMs = try {
|
||||||
|
callLink.state.expiration.toEpochMilli()
|
||||||
|
} catch (e: ArithmeticException) { Long.MAX_VALUE },
|
||||||
restrictions = callLink.state.restrictions.toBackup()
|
restrictions = callLink.state.restrictions.toBackup()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -180,6 +180,8 @@ class ChatItemImportInserter(
|
||||||
}
|
}
|
||||||
val messageInsert = chatItem.toMessageInsert(fromLocalRecipientId, chatLocalRecipientId, localThreadId)
|
val messageInsert = chatItem.toMessageInsert(fromLocalRecipientId, chatLocalRecipientId, localThreadId)
|
||||||
if (chatItem.revisions.isNotEmpty()) {
|
if (chatItem.revisions.isNotEmpty()) {
|
||||||
|
// Flush to avoid having revisions cross batch boundaries, which will cause a foreign key failure
|
||||||
|
flush()
|
||||||
val originalId = messageId
|
val originalId = messageId
|
||||||
val latestRevisionId = originalId + chatItem.revisions.size
|
val latestRevisionId = originalId + chatItem.revisions.size
|
||||||
val sortedRevisions = chatItem.revisions.sortedBy { it.dateSent }.map { it.toMessageInsert(fromLocalRecipientId, chatLocalRecipientId, localThreadId) }
|
val sortedRevisions = chatItem.revisions.sortedBy { it.dateSent }.map { it.toMessageInsert(fromLocalRecipientId, chatLocalRecipientId, localThreadId) }
|
||||||
|
|
|
@ -32,7 +32,7 @@ public final class GroupCallUpdateDetailsUtil {
|
||||||
*/
|
*/
|
||||||
public static @NonNull String createBodyFromBackup(@NonNull GroupCall groupCallChatUpdate, ServiceId.ACI startedCallAci) {
|
public static @NonNull String createBodyFromBackup(@NonNull GroupCall groupCallChatUpdate, ServiceId.ACI startedCallAci) {
|
||||||
GroupCallUpdateDetails details = new GroupCallUpdateDetails.Builder()
|
GroupCallUpdateDetails details = new GroupCallUpdateDetails.Builder()
|
||||||
.startedCallUuid(Objects.toString(startedCallAci, null))
|
.startedCallUuid(Objects.toString(startedCallAci, ""))
|
||||||
.startedCallTimestamp(groupCallChatUpdate.startedCallTimestamp)
|
.startedCallTimestamp(groupCallChatUpdate.startedCallTimestamp)
|
||||||
.endedCallTimestamp(groupCallChatUpdate.endedCallTimestamp)
|
.endedCallTimestamp(groupCallChatUpdate.endedCallTimestamp)
|
||||||
.isCallFull(false)
|
.isCallFull(false)
|
||||||
|
|
|
@ -22,7 +22,6 @@ import kotlinx.coroutines.withContext
|
||||||
import org.signal.core.util.Stopwatch
|
import org.signal.core.util.Stopwatch
|
||||||
import org.signal.core.util.isNotNullOrBlank
|
import org.signal.core.util.isNotNullOrBlank
|
||||||
import org.signal.core.util.logging.Log
|
import org.signal.core.util.logging.Log
|
||||||
import org.thoughtcrime.securesms.backup.v2.BackupRepository
|
|
||||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob
|
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob
|
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob
|
||||||
|
@ -772,8 +771,6 @@ class RegistrationViewModel : ViewModel() {
|
||||||
Log.v(TAG, "onSuccessfulRegistration()")
|
Log.v(TAG, "onSuccessfulRegistration()")
|
||||||
RegistrationRepository.registerAccountLocally(context, registrationData, remoteResult, reglockEnabled)
|
RegistrationRepository.registerAccountLocally(context, registrationData, remoteResult, reglockEnabled)
|
||||||
|
|
||||||
restoreBackupTier()
|
|
||||||
|
|
||||||
if (reglockEnabled) {
|
if (reglockEnabled) {
|
||||||
SignalStore.onboarding.clearAll()
|
SignalStore.onboarding.clearAll()
|
||||||
val stopwatch = Stopwatch("RegistrationLockRestore")
|
val stopwatch = Stopwatch("RegistrationLockRestore")
|
||||||
|
@ -864,12 +861,6 @@ class RegistrationViewModel : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
private val TAG = Log.tag(RegistrationViewModel::class.java)
|
private val TAG = Log.tag(RegistrationViewModel::class.java)
|
||||||
|
|
||||||
private suspend fun restoreBackupTier() = withContext(Dispatchers.IO) {
|
|
||||||
val startTime = System.currentTimeMillis()
|
|
||||||
BackupRepository.restoreBackupTier()
|
|
||||||
Log.i(TAG, "Took " + (System.currentTimeMillis() - startTime) + " ms to restore the backup tier..")
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun refreshRemoteConfig() = withContext(Dispatchers.IO) {
|
private suspend fun refreshRemoteConfig() = withContext(Dispatchers.IO) {
|
||||||
val startTime = System.currentTimeMillis()
|
val startTime = System.currentTimeMillis()
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue