mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 19:00:26 +01:00
Add job to fix digests for duplicate attachments.
This commit is contained in:
@@ -157,9 +157,10 @@ public class ApplicationMigrations {
|
||||
static final int BACKFILL_DIGESTS_V2 = 113;
|
||||
static final int CALL_LINK_STORAGE_SYNC = 114;
|
||||
static final int WALLPAPER_MIGRATION = 115;
|
||||
static final int BACKFILL_DIGESTS_V3 = 116;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 115;
|
||||
public static final int CURRENT_VERSION = 116;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -718,6 +719,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.WALLPAPER_MIGRATION, new WallpaperStorageMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.BACKFILL_DIGESTS_V3) {
|
||||
jobs.put(Version.BACKFILL_DIGESTS_V3, new BackfillDigestsForDuplicatesMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
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.BackfillDigestsForDataFileJob
|
||||
|
||||
/**
|
||||
* Finds all attachments that share a data file and schedules a [BackfillDigestsForDataFileJob] for each.
|
||||
*/
|
||||
internal class BackfillDigestsForDuplicatesMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
private val TAG = Log.tag(BackfillDigestsForDuplicatesMigrationJob::class.java)
|
||||
const val KEY = "BackfillDigestsForDuplicatesMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
val jobs = SignalDatabase.attachments.getDataFilesWithMultipleValidAttachments()
|
||||
.map { BackfillDigestsForDataFileJob(it) }
|
||||
|
||||
AppDependencies.jobManager.addAll(jobs)
|
||||
|
||||
Log.i(TAG, "Enqueued ${jobs.size} backfill digest jobs for duplicate attachments.")
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<BackfillDigestsForDuplicatesMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): BackfillDigestsForDuplicatesMigrationJob {
|
||||
return BackfillDigestsForDuplicatesMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user