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