mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 10:51:27 +01:00
Clean up dangling wallpapers.
This commit is contained in:
@@ -159,9 +159,10 @@ public class ApplicationMigrations {
|
||||
static final int WALLPAPER_MIGRATION = 115;
|
||||
static final int BACKFILL_DIGESTS_V3 = 116;
|
||||
static final int SVR2_ENCLAVE_UPDATE_2 = 117;
|
||||
static final int WALLPAPER_MIGRATION_CLEANUP = 118;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 117;
|
||||
public static final int CURRENT_VERSION = 118;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -728,6 +729,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.SVR2_ENCLAVE_UPDATE_2, new Svr2MirrorMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.WALLPAPER_MIGRATION_CLEANUP) {
|
||||
jobs.put(Version.WALLPAPER_MIGRATION_CLEANUP, new WallpaperCleanupMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
|
||||
/**
|
||||
* [WallpaperStorageMigrationJob] left some stragglers in the DB for wallpapers that couldn't be found on disk. This cleans those up.
|
||||
* It'd be great if we could do this in a database migration, but unfortunately we need to ensure that the aforementioned
|
||||
* [WallpaperStorageMigrationJob] finished.
|
||||
*/
|
||||
internal class WallpaperCleanupMigrationJob(parameters: Parameters = Parameters.Builder().build()) : MigrationJob(parameters) {
|
||||
companion object {
|
||||
private val TAG = Log.tag(WallpaperCleanupMigrationJob::class.java)
|
||||
const val KEY = "WallpaperCleanupMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
val count = SignalDatabase.recipients.clearMissingFileWallpapersPostMigration()
|
||||
if (count > 0) {
|
||||
Log.w(TAG, "There were $count legacy wallpapers that needed to be cleared.")
|
||||
} else {
|
||||
Log.i(TAG, "No legacy wallpapers needed to be cleared.")
|
||||
}
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<WallpaperCleanupMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): WallpaperCleanupMigrationJob {
|
||||
return WallpaperCleanupMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user