mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Only run BackupMessageJob after the digest backfill has finished.
This commit is contained in:
committed by
Cody Henthorne
parent
c4bcb7dc93
commit
a7b958d811
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user