Add backstop for ensuring attachment archive jobs are enqueued.

This commit is contained in:
Greyson Parrelli
2025-09-02 19:04:01 -04:00
parent 3b715bc461
commit 71dd1d9d8b
4 changed files with 35 additions and 0 deletions

View File

@@ -868,6 +868,17 @@ class AttachmentTable(
}
}
/**
* Resets the [ARCHIVE_TRANSFER_STATE] of any attachments that are currently in-progress of uploading.
*/
fun clearArchiveTransferStateForInProgressItems(): Int {
return writableDatabase
.update(TABLE_NAME)
.values(ARCHIVE_TRANSFER_STATE to ArchiveTransferState.NONE.value)
.where("$ARCHIVE_TRANSFER_STATE IN (${ArchiveTransferState.UPLOAD_IN_PROGRESS.value}, ${ArchiveTransferState.COPY_PENDING.value}, ${ArchiveTransferState.TEMPORARY_FAILURE.value})")
.run()
}
/**
* Marks eligible attachments as offloaded based on their received at timestamp, their last restore time,
* presence of thumbnail if media, and the full file being available in the archive.