From 8373eaeb7db3461c2f533ddcf920677664dcce4a Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 31 Aug 2022 16:13:33 +0200 Subject: [PATCH] Fixed manual download of a content that tried to be auto-downloaded but failed --- .../main/chat/data/ChatMessageContentData.kt | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/linphone/activities/main/chat/data/ChatMessageContentData.kt b/app/src/main/java/org/linphone/activities/main/chat/data/ChatMessageContentData.kt index e155c900f..5fd54ad0a 100644 --- a/app/src/main/java/org/linphone/activities/main/chat/data/ChatMessageContentData.kt +++ b/app/src/main/java/org/linphone/activities/main/chat/data/ChatMessageContentData.kt @@ -176,22 +176,27 @@ class ChatMessageContentData( val content = getContent() val filePath = content.filePath - if (content.isFileTransfer && (filePath == null || filePath.isEmpty())) { - val contentName = content.name - if (contentName != null) { - val file = FileUtils.getFileStoragePath(contentName) - content.filePath = file.path - downloadEnabled.value = false - - Log.i("[Content] Started downloading $contentName into ${content.filePath}") - if (!chatMessage.downloadContent(content)) { - Log.e("[Content] Failed to start content download!") + if (content.isFileTransfer) { + if (filePath == null || filePath.isEmpty()) { + val contentName = content.name + if (contentName != null) { + val file = FileUtils.getFileStoragePath(contentName) + content.filePath = file.path + Log.i("[Content] Started downloading $contentName into ${content.filePath}") + } else { + Log.e("[Content] Content name is null, can't download it!") + return } } 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 { - 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!") } }