Add support for backing up wallpapers.

This commit is contained in:
Greyson Parrelli
2024-09-20 12:24:57 -04:00
committed by GitHub
parent e14078d2ec
commit a7bdfb6d76
30 changed files with 907 additions and 410 deletions

View File

@@ -66,9 +66,11 @@ class BackupRestoreMediaJob private constructor(parameters: Parameters) : BaseJo
val messageMap = SignalDatabase.messages.getMessages(messageIds).associate { it.id to (it as MmsMessageRecord) }
for (attachment in attachmentBatch) {
val isWallpaper = attachment.mmsId == AttachmentTable.WALLPAPER_MESSAGE_ID
val message = messageMap[attachment.mmsId]
if (message == null) {
Log.w(TAG, "Unable to find message for ${attachment.attachmentId}")
if (message == null && !isWallpaper) {
Log.w(TAG, "Unable to find message for ${attachment.attachmentId}, mmsId: ${attachment.mmsId}")
notRestorable += attachment
continue
}
@@ -79,7 +81,7 @@ class BackupRestoreMediaJob private constructor(parameters: Parameters) : BaseJo
highPriority = false
)
if (shouldRestoreFullSize(message, restoreTime, SignalStore.backup.optimizeStorage)) {
if (isWallpaper || shouldRestoreFullSize(message!!, restoreTime, SignalStore.backup.optimizeStorage)) {
restoreFullAttachmentJobs += attachment to RestoreAttachmentJob(
messageId = attachment.mmsId,
attachmentId = attachment.attachmentId

View File

@@ -94,6 +94,7 @@ import org.thoughtcrime.securesms.migrations.TrimByLengthSettingsMigrationJob;
import org.thoughtcrime.securesms.migrations.UpdateSmsJobsMigrationJob;
import org.thoughtcrime.securesms.migrations.UserNotificationMigrationJob;
import org.thoughtcrime.securesms.migrations.UuidMigrationJob;
import org.thoughtcrime.securesms.migrations.WallpaperStorageMigrationJob;
import java.util.Arrays;
import java.util.HashMap;
@@ -309,6 +310,7 @@ public final class JobManagerFactories {
put(UpdateSmsJobsMigrationJob.KEY, new UpdateSmsJobsMigrationJob.Factory());
put(UserNotificationMigrationJob.KEY, new UserNotificationMigrationJob.Factory());
put(UuidMigrationJob.KEY, new UuidMigrationJob.Factory());
put(WallpaperStorageMigrationJob.KEY, new WallpaperStorageMigrationJob.Factory());
// Dead jobs
put(FailingJob.KEY, new FailingJob.Factory());