Backfill missing attachment hashes.

This commit is contained in:
Greyson Parrelli
2024-03-15 13:29:47 -04:00
committed by Cody Henthorne
parent 6df1a68213
commit 1d29b0166d
7 changed files with 451 additions and 2 deletions

View File

@@ -145,11 +145,12 @@ public class ApplicationMigrations {
static final int STORAGE_LOCAL_UNKNOWNS_FIX = 101;
static final int PNP_LAUNCH = 102;
static final int EMOJI_VERSION_10 = 103;
static final int ATTACHMENT_HASH_BACKFILL = 104;
}
public static final int CURRENT_VERSION = 103;
public static final int CURRENT_VERSION = 104;
/**
/**
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
* to {@link JobManager#beginJobLoop()}. Otherwise, other non-migration jobs may have started
* executing before we add the migration jobs.
@@ -662,6 +663,10 @@ public class ApplicationMigrations {
jobs.put(Version.EMOJI_VERSION_10, new EmojiDownloadMigrationJob());
}
if (lastSeenVersion < Version.ATTACHMENT_HASH_BACKFILL) {
jobs.put(Version.ATTACHMENT_HASH_BACKFILL, new AttachmentHashBackfillMigrationJob());
}
return jobs;
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2024 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.migrations
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobs.AttachmentHashBackfillJob
import java.lang.Exception
/**
* Kicks off the attachment hash backfill process by enqueueing a [AttachmentHashBackfillJob].
*/
internal class AttachmentHashBackfillMigrationJob(parameters: Parameters = Parameters.Builder().build()) : MigrationJob(parameters) {
companion object {
val TAG = Log.tag(AttachmentHashBackfillMigrationJob::class.java)
const val KEY = "AttachmentHashBackfillMigrationJob"
}
override fun getFactoryKey(): String = KEY
override fun isUiBlocking(): Boolean = false
override fun performMigration() {
ApplicationDependencies.getJobManager().add(AttachmentHashBackfillJob())
}
override fun shouldRetry(e: Exception): Boolean = false
class Factory : Job.Factory<AttachmentHashBackfillMigrationJob> {
override fun create(parameters: Parameters, serializedData: ByteArray?): AttachmentHashBackfillMigrationJob {
return AttachmentHashBackfillMigrationJob(parameters)
}
}
}