Fixed manual download of a content that tried to be auto-downloaded but failed

This commit is contained in:
Sylvain Berfini 2022-08-31 16:13:33 +02:00
parent 05ddd072a3
commit 8373eaeb7d

View file

@ -176,22 +176,27 @@ class ChatMessageContentData(
val content = getContent() val content = getContent()
val filePath = content.filePath val filePath = content.filePath
if (content.isFileTransfer && (filePath == null || filePath.isEmpty())) { if (content.isFileTransfer) {
val contentName = content.name if (filePath == null || filePath.isEmpty()) {
if (contentName != null) { val contentName = content.name
val file = FileUtils.getFileStoragePath(contentName) if (contentName != null) {
content.filePath = file.path val file = FileUtils.getFileStoragePath(contentName)
downloadEnabled.value = false content.filePath = file.path
Log.i("[Content] Started downloading $contentName into ${content.filePath}")
Log.i("[Content] Started downloading $contentName into ${content.filePath}") } else {
if (!chatMessage.downloadContent(content)) { Log.e("[Content] Content name is null, can't download it!")
Log.e("[Content] Failed to start content download!") return
} }
} else { } else {
Log.e("[Content] Content name is null, can't download it!") Log.w("[Content] File path already set [$filePath] using it (auto download that failed probably)")
}
downloadEnabled.value = false
if (!chatMessage.downloadContent(content)) {
Log.e("[Content] Failed to start content download!")
} }
} else { } else {
Log.e("[Content] Either content is not a FileTransfer or it's filePath has already been set, can't download it anyway!") Log.e("[Content] Content is not a FileTransfer, can't download it!")
} }
} }