mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-26 12:44:38 +00:00
Only enqueue attachment archive syncing jobs if the user backs up media.
This commit is contained in:
committed by
Jeffrey Starke
parent
e6aed8534a
commit
015a34f8d6
@@ -71,6 +71,11 @@ class ArchiveAttachmentReconciliationJob private constructor(
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun run(): Result {
|
||||
if (!SignalStore.backup.backsUpMedia) {
|
||||
Log.w(TAG, "This user doesn't back up media! Skipping.")
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
val timeSinceLastSync = System.currentTimeMillis() - SignalStore.backup.lastAttachmentReconciliationTime
|
||||
if (!forced && serverCursor == null && timeSinceLastSync > 0 && timeSinceLastSync < RemoteConfig.archiveReconciliationSyncInterval.inWholeMilliseconds) {
|
||||
Log.d(TAG, "No need to do a remote sync yet. Time since last sync: $timeSinceLastSync ms")
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.thoughtcrime.securesms.backup.v2.BackupRepository
|
||||
import org.thoughtcrime.securesms.database.BackupMediaSnapshotTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.whispersystems.signalservice.api.NetworkResult
|
||||
import java.lang.RuntimeException
|
||||
import kotlin.time.Duration.Companion.days
|
||||
@@ -96,6 +97,11 @@ class ArchiveCommitAttachmentDeletesJob private constructor(parameters: Paramete
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun run(): Result {
|
||||
if (!SignalStore.backup.backsUpMedia) {
|
||||
Log.w(TAG, "This user doesn't back up media! Skipping.")
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
var mediaObjects = SignalDatabase.backupMediaSnapshots.getPageOfOldMediaObjects(REMOTE_DELETE_BATCH_SIZE)
|
||||
|
||||
while (mediaObjects.isNotEmpty()) {
|
||||
|
||||
@@ -240,8 +240,10 @@ class BackupMessagesJob private constructor(
|
||||
BackupRepository.clearBackupFailure()
|
||||
SignalDatabase.backupMediaSnapshots.commitPendingRows()
|
||||
|
||||
AppDependencies.jobManager.add(ArchiveCommitAttachmentDeletesJob())
|
||||
AppDependencies.jobManager.add(ArchiveAttachmentReconciliationJob())
|
||||
if (SignalStore.backup.backsUpMedia) {
|
||||
AppDependencies.jobManager.add(ArchiveCommitAttachmentDeletesJob())
|
||||
AppDependencies.jobManager.add(ArchiveAttachmentReconciliationJob())
|
||||
}
|
||||
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user