Only run BackupMessageJob after the digest backfill has finished.

This commit is contained in:
Greyson Parrelli
2024-09-06 16:37:18 -04:00
committed by Cody Henthorne
parent c4bcb7dc93
commit a7b958d811
2 changed files with 6 additions and 4 deletions

View File

@@ -34,12 +34,13 @@ class BackfillDigestJob private constructor(
companion object {
private val TAG = Log.tag(BackfillDigestJob::class)
const val KEY = "BackfillDigestJob"
const val QUEUE = "BackfillDigestJob"
}
constructor(attachmentId: AttachmentId) : this(
attachmentId = attachmentId,
params = Parameters.Builder()
.setQueue("BackfillDigestJob")
.setQueue(QUEUE)
.setMaxAttempts(3)
.setLifespan(Parameters.IMMORTAL)
.build()

View File

@@ -34,8 +34,6 @@ class BackupMessagesJob private constructor(parameters: Parameters) : BaseJob(pa
const val KEY = "BackupMessagesJob"
const val QUEUE = "BackupMessagesQueue"
/**
* Pruning abandoned remote media is relatively expensive, so we should
* not do this every time we backup.
@@ -58,7 +56,7 @@ class BackupMessagesJob private constructor(parameters: Parameters) : BaseJob(pa
.addConstraint(if (SignalStore.backup.backupWithCellular) NetworkConstraint.KEY else WifiConstraint.KEY)
.setMaxAttempts(3)
.setMaxInstancesForFactory(1)
.setQueue(QUEUE)
.setQueue(BackfillDigestJob.QUEUE) // We want to ensure digests have been backfilled before this runs. Could eventually remove this constraint.b
.build()
)
@@ -131,12 +129,15 @@ class BackupMessagesJob private constructor(parameters: Parameters) : BaseJob(pa
FileInputStream(tempBackupFile).use {
BackupRepository.uploadBackupFile(it, tempBackupFile.length())
}
val needBackfill = archiveAttachments()
SignalStore.backup.lastBackupProtoSize = tempBackupFile.length()
if (!tempBackupFile.delete()) {
Log.e(TAG, "Failed to delete temp backup file")
}
SignalStore.backup.lastBackupTime = System.currentTimeMillis()
if (!needBackfill) {
EventBus.getDefault().postSticky(BackupV2Event(BackupV2Event.Type.FINISHED, 0, 0))
try {