mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Prevent duplicate restore local attachment jobs from being enqueue.
This commit is contained in:
@@ -70,6 +70,7 @@ class RestoreLocalAttachmentJob private constructor(
|
||||
SignalDatabase.attachments.setRestoreTransferState(notRestorableAttachments, AttachmentTable.TRANSFER_PROGRESS_FAILED)
|
||||
|
||||
// Intentionally enqueues one at a time for safer attachment transfer state management
|
||||
Log.d(TAG, "Adding ${restoreAttachmentJobs.size} restore local attachment jobs")
|
||||
restoreAttachmentJobs.forEach { jobManager.add(it) }
|
||||
} while (restoreAttachmentJobs.isNotEmpty())
|
||||
|
||||
@@ -100,7 +101,7 @@ class RestoreLocalAttachmentJob private constructor(
|
||||
size = info.size
|
||||
)
|
||||
|
||||
override fun serialize(): ByteArray? {
|
||||
override fun serialize(): ByteArray {
|
||||
return RestoreLocalAttachmentJobData(
|
||||
attachmentId = attachmentId.id,
|
||||
messageId = messageId,
|
||||
@@ -113,6 +114,10 @@ class RestoreLocalAttachmentJob private constructor(
|
||||
return KEY
|
||||
}
|
||||
|
||||
override fun onAdded() {
|
||||
SignalDatabase.attachments.setRestoreTransferState(attachmentId, AttachmentTable.TRANSFER_RESTORE_IN_PROGRESS)
|
||||
}
|
||||
|
||||
override fun run(): Result {
|
||||
Log.i(TAG, "onRun() messageId: $messageId attachmentId: $attachmentId")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user