Make backup jobs cancelable.

This commit is contained in:
Greyson Parrelli
2024-10-09 21:45:33 -04:00
parent 58a48e38eb
commit dcb5015290
8 changed files with 117 additions and 12 deletions

View File

@@ -1068,6 +1068,23 @@ class AttachmentTable(
}
}
/**
* Updates the attachment (and all attachments that share the same data file) with a new length.
*/
fun updateAttachmentLength(attachmentId: AttachmentId, length: Long) {
val dataFile = getDataFileInfo(attachmentId)
if (dataFile == null) {
Log.w(TAG, "[$attachmentId] Failed to find data file!")
return
}
writableDatabase
.update(TABLE_NAME)
.values(DATA_SIZE to length)
.where("$DATA_FILE = ?", dataFile.file.absolutePath)
.run()
}
/**
* When we find out about a new inbound attachment pointer, we insert a row for it that contains all the info we need to download it via [insertAttachmentWithData].
* Later, we download the data for that pointer. Call this method once you have the data to associate it with the attachment. At this point, it is assumed
@@ -2804,7 +2821,10 @@ class AttachmentTable(
FINISHED(3),
/** It is impossible to upload this attachment. */
PERMANENT_FAILURE(4);
PERMANENT_FAILURE(4),
/** Upload failed, but in a way where it may be worth retrying later. */
TEMPORARY_FAILURE(5);
companion object {
fun deserialize(value: Int): ArchiveTransferState {