feat: add drop attachment download migration in case there are a lot of pending failed attachment downloads

pull/1339/head
0x330a 5 months ago
parent 6f22eb659b
commit 862a47e7e3
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C

@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.database
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import org.session.libsession.messaging.jobs.AttachmentDownloadJob
import org.session.libsession.messaging.jobs.AttachmentUploadJob
import org.session.libsession.messaging.jobs.BackgroundGroupAddJob
import org.session.libsession.messaging.jobs.GroupAvatarDownloadJob
@ -26,6 +27,9 @@ class SessionJobDatabase(context: Context, helper: SQLCipherOpenHelper) : Databa
const val serializedData = "serialized_data"
@JvmStatic val createSessionJobTableCommand
= "CREATE TABLE $sessionJobTable ($jobID INTEGER PRIMARY KEY, $jobType STRING, $failureCount INTEGER DEFAULT 0, $serializedData TEXT);"
const val dropAttachmentDownloadJobs =
"DELETE FROM $sessionJobTable WHERE $jobType = ${AttachmentDownloadJob.KEY};"
}
fun persistJob(job: Job) {

@ -90,8 +90,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV42 = 63;
private static final int lokiV43 = 64;
private static final int lokiV44 = 65;
// Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes
private static final int DATABASE_VERSION = lokiV43;
private static final int DATABASE_VERSION = lokiV44;
private static final int MIN_DATABASE_VERSION = lokiV7;
private static final String CIPHER3_DATABASE_NAME = "signal.db";
public static final String DATABASE_NAME = "signal_v4.db";
@ -604,6 +606,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
db.execSQL(RecipientDatabase.getAddBlocksCommunityMessageRequests());
}
if (oldVersion < lokiV44) {
db.execSQL(SessionJobDatabase.dropAttachmentDownloadJobs);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();

@ -35,7 +35,7 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long)
override val maxFailureCount: Int = 2
companion object {
val KEY: String = "AttachmentDownloadJob"
const val KEY: String = "AttachmentDownloadJob"
// Keys used for database storage
private val ATTACHMENT_ID_KEY = "attachment_id"

Loading…
Cancel
Save