Fix potential performance issues during backup attachment upload.

This commit is contained in:
Greyson Parrelli
2025-11-19 10:37:43 -05:00
committed by Cody Henthorne
parent eebf3e0836
commit 7978cc668d
7 changed files with 199 additions and 91 deletions

View File

@@ -924,7 +924,7 @@ class AttachmentTable(
/**
* Sets the archive transfer state for the given attachment and all other attachments that share the same data file.
*/
fun setArchiveTransferState(id: AttachmentId, state: ArchiveTransferState) {
fun setArchiveTransferState(id: AttachmentId, state: ArchiveTransferState, notify: Boolean = true) {
writableDatabase.withinTransaction {
val dataFile: String = readableDatabase
.select(DATA_FILE)
@@ -940,14 +940,16 @@ class AttachmentTable(
.run()
}
AppDependencies.databaseObserver.notifyAttachmentUpdatedObservers()
if (notify) {
AppDependencies.databaseObserver.notifyAttachmentUpdatedObservers()
}
}
/**
* Sets the archive transfer state for the given attachment id, remote key, and plain text hash tuple and all other attachments that
* share the same data file.
*/
fun setArchiveTransferState(id: AttachmentId, remoteKey: String, plaintextHash: String, state: ArchiveTransferState): Boolean {
fun setArchiveTransferState(id: AttachmentId, remoteKey: String, plaintextHash: String, state: ArchiveTransferState, notify: Boolean = true): Boolean {
writableDatabase.withinTransaction {
val dataFile: String = readableDatabase
.select(DATA_FILE)
@@ -963,7 +965,9 @@ class AttachmentTable(
.run()
}
AppDependencies.databaseObserver.notifyAttachmentUpdatedObservers()
if (notify) {
AppDependencies.databaseObserver.notifyAttachmentUpdatedObservers()
}
return true
}