aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>1970-01-01 00:00:00 +0000
committerlink2xt <link2xt@testrun.org>1970-01-01 00:00:00 +0000
commitd4c66cd1341084b37dfabe3126d13ff8f062fd59 (patch)
treee0069020f47fd56f163ec7f9e0dc00d6b05c0b5f
parent75043d4d2d90c56ad5d8ef16d69073144238f81c (diff)
downloadkdeltachat-d4c66cd1341084b37dfabe3126d13ff8f062fd59.tar.gz
kdeltachat-d4c66cd1341084b37dfabe3126d13ff8f062fd59.zip
Do not copy attachments to blobdir manually
If QFile::copy() fails because blobdir already contains an image with the same file name (could be something common, e.g., "1.jpg"), we end up sending completely wrong file. Delta Chat core (dc_send_msg) already does the copying for us and resolves filename conflicts.
-rw-r--r--context.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/context.cpp b/context.cpp
index a138dd7..1fa24af 100644
--- a/context.cpp
+++ b/context.cpp
@@ -269,18 +269,10 @@ Context::newMessage(int viewtype)
uint32_t
Context::sendMessage(uint32_t chatId, DcMessage *message, QString attachment)
{
- QByteArray utf8attachFilename = attachment.toUtf8();
- if(strlen(utf8attachFilename.constData()) > 0){
+ if (!attachment.isEmpty()) {
+ QByteArray utf8attachFilename = attachment.toUtf8();
dc_msg_set_file(message->m_message, utf8attachFilename.constData(), NULL);
-
- QString ImgBlobPath;
- QTextStream (&ImgBlobPath) << dc_get_blobdir(m_context) << "/" << dc_msg_get_filename(message->m_message);
-
- printf("\nPush it into blob dir :%s\n", ImgBlobPath.toUtf8().constData());
- QFile::copy(attachment, ImgBlobPath.toUtf8().constData());
- dc_msg_set_file(message->m_message, ImgBlobPath.toUtf8().constData(), NULL);
}
- dc_prepare_msg(m_context, chatId, message->m_message);
return dc_send_msg(m_context, chatId, message->m_message);
}