mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Convert avatar migration to just be a force push.
This commit is contained in:
committed by
Cody Henthorne
parent
138dae0484
commit
e45eabc714
@@ -1,20 +1,11 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.requireLong
|
||||
import org.signal.core.util.select
|
||||
import org.signal.core.util.withinTransaction
|
||||
import org.thoughtcrime.securesms.database.RecipientTable
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.Companion.ID
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.Companion.STORAGE_SERVICE_ID
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.Companion.TABLE_NAME
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.Companion.TYPE
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.StorageForcePushJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
|
||||
/**
|
||||
* A job that marks all contacts and groups as needing to be synced, so that we'll update the
|
||||
@@ -42,27 +33,11 @@ internal class AvatarColorStorageServiceMigrationJob(
|
||||
return
|
||||
}
|
||||
|
||||
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
|
||||
SignalDatabase.recipients.markAllContactsAndGroupsAsNeedsSync()
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
AppDependencies.jobManager.add(StorageForcePushJob())
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
private fun RecipientTable.markAllContactsAndGroupsAsNeedsSync() {
|
||||
writableDatabase.withinTransaction { db ->
|
||||
db.select(ID)
|
||||
.from(TABLE_NAME)
|
||||
.where("$STORAGE_SERVICE_ID NOT NULL AND $TYPE IN (${RecipientTable.RecipientType.INDIVIDUAL.id}, ${RecipientTable.RecipientType.GV2.id})")
|
||||
.run()
|
||||
.use { cursor ->
|
||||
while (cursor.moveToNext()) {
|
||||
rotateStorageId(RecipientId.from(cursor.requireLong(ID)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Factory : Job.Factory<AvatarColorStorageServiceMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): AvatarColorStorageServiceMigrationJob {
|
||||
return AvatarColorStorageServiceMigrationJob(parameters)
|
||||
|
||||
Reference in New Issue
Block a user