only deleting voice files if they were successfully uploading

- fixes flaky networks losing the voice file and being unable to retry
This commit is contained in:
Adam Brown 2021-11-23 17:45:10 +00:00
parent c72dd5eec6
commit bdf9402685

View file

@ -279,6 +279,11 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
Timber.e(failure, "## Failed to update file cache")
}
// Delete the temporary voice message file
if (params.attachment.type == ContentAttachmentData.Type.AUDIO && params.attachment.mimeType == MimeTypes.Ogg) {
context.contentResolver.delete(params.attachment.queryUri, null, null)
}
val uploadThumbnailResult = dealWithThumbnail(params)
handleSuccess(params,
@ -299,11 +304,6 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
filesToDelete.forEach {
tryOrNull { it.delete() }
}
// Delete the temporary voice message file
if (params.attachment.type == ContentAttachmentData.Type.AUDIO && params.attachment.mimeType == MimeTypes.Ogg) {
context.contentResolver.delete(params.attachment.queryUri, null, null)
}
}
}