mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-24 03:35:58 +00:00
Fix upload to archive running while not on wifi.
This commit is contained in:
@@ -856,7 +856,7 @@ class AttachmentTable(
|
||||
.where(
|
||||
"""
|
||||
$ARCHIVE_TRANSFER_STATE = ${ArchiveTransferState.FINISHED.value} AND
|
||||
$ARCHIVE_THUMBNAIL_TRANSFER_STATE = ${ArchiveTransferState.NONE.value} AND
|
||||
$ARCHIVE_THUMBNAIL_TRANSFER_STATE IN (${ArchiveTransferState.NONE.value}, ${ArchiveTransferState.TEMPORARY_FAILURE.value}) AND
|
||||
$QUOTE = 0 AND
|
||||
($CONTENT_TYPE LIKE 'image/%' OR $CONTENT_TYPE LIKE 'video/%') AND
|
||||
$CONTENT_TYPE != 'image/svg+xml'
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.BackupMessagesConstraint
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NoRemoteArchiveGarbageCollectionPendingConstraint
|
||||
import org.thoughtcrime.securesms.jobmanager.persistence.JobSpec
|
||||
import org.thoughtcrime.securesms.jobs.protos.ArchiveThumbnailUploadJobData
|
||||
@@ -79,7 +79,7 @@ class ArchiveThumbnailUploadJob private constructor(
|
||||
constructor(attachmentId: AttachmentId) : this(
|
||||
Parameters.Builder()
|
||||
.setQueue(QUEUES.random())
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.addConstraint(BackupMessagesConstraint.KEY)
|
||||
.addConstraint(NoRemoteArchiveGarbageCollectionPendingConstraint.KEY)
|
||||
.setLifespan(1.days.inWholeMilliseconds)
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
@@ -105,6 +105,11 @@ class ArchiveThumbnailUploadJob private constructor(
|
||||
}
|
||||
|
||||
override fun run(): Result {
|
||||
// TODO [cody] Remove after a few releases as we migrate to the correct constraint
|
||||
if (!BackupMessagesConstraint.isMet(context)) {
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
val attachment = SignalDatabase.attachments.getAttachment(attachmentId)
|
||||
if (attachment == null) {
|
||||
Log.w(TAG, "$attachmentId not found, assuming this job is no longer necessary.")
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.BackupMessagesConstraint
|
||||
import org.thoughtcrime.securesms.jobs.protos.UploadAttachmentToArchiveJobData
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
@@ -76,7 +76,7 @@ class UploadAttachmentToArchiveJob private constructor(
|
||||
uploadSpec = null,
|
||||
canReuseUpload = canReuseUpload,
|
||||
parameters = Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.addConstraint(BackupMessagesConstraint.KEY)
|
||||
.setLifespan(30.days.inWholeMilliseconds)
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
.setQueue(QUEUES.random())
|
||||
@@ -102,6 +102,11 @@ class UploadAttachmentToArchiveJob private constructor(
|
||||
}
|
||||
|
||||
override fun run(): Result {
|
||||
// TODO [cody] Remove after a few releases as we migrate to the correct constraint
|
||||
if (!BackupMessagesConstraint.isMet(context)) {
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
if (SignalStore.account.isLinkedDevice) {
|
||||
Log.w(TAG, "[$attachmentId] Linked devices don't backup media. Skipping.")
|
||||
SignalDatabase.attachments.setArchiveTransferState(attachmentId, AttachmentTable.ArchiveTransferState.NONE)
|
||||
|
||||
Reference in New Issue
Block a user