mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Add migration to backfill digests.
This commit is contained in:
committed by
Cody Henthorne
parent
a8bf03af89
commit
d59985c7b1
@@ -154,9 +154,10 @@ public class ApplicationMigrations {
|
||||
static final int EXPIRE_TIMER_CAPABILITY = 109;
|
||||
static final int REBUILD_MESSAGE_FTS_INDEX_6 = 110;
|
||||
static final int EXPIRE_TIMER_CAPABILITY_2 = 111;
|
||||
static final int BACKFILL_DIGESTS = 112;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 111;
|
||||
public static final int CURRENT_VERSION = 112;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -703,6 +704,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.EXPIRE_TIMER_CAPABILITY_2, new AttributesMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.BACKFILL_DIGESTS) {
|
||||
jobs.put(Version.BACKFILL_DIGESTS, new BackfillDigestsMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.BackfillDigestJob
|
||||
|
||||
/**
|
||||
* Finds all attachments that need new digests and schedules a [BackfillDigestJob] for each.
|
||||
*/
|
||||
internal class BackfillDigestsMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
val TAG = Log.tag(BackfillDigestsMigrationJob::class.java)
|
||||
const val KEY = "BackfillDigestsMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
val jobs = SignalDatabase.attachments.getAttachmentsThatNeedNewDigests()
|
||||
.map { BackfillDigestJob(it) }
|
||||
|
||||
AppDependencies.jobManager.addAll(jobs)
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<BackfillDigestsMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): BackfillDigestsMigrationJob {
|
||||
return BackfillDigestsMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user