[network/kdeconnect-kde/release/26.08] plugins/sms: sms: give up on an attachment that cannot be read
Albert Vaca Cintora <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 0d9995385fe5521ab782de6753a0995e12ad1910 by Albert Vaca Cintora, on behalf of Méven Car.
Committed on 28/07/2026 at 05:27.
Pushed by albertvaka into branch 'release/26.08'.
sms: give up on an attachment that cannot be read
The return value of QFile::open was dropped, which the compiler points out
now that the method is marked nodiscard. What stood in for it was a call to
QFile::exists, so a file that is there but cannot be read went on to be sent
as an attachment with no content in it.
Take the answer from open and say in the log why the attachment is being
dropped. An open that succeeds already tells us the file is there, so the
call to exists goes away with it.
(cherry picked from commit 3a6bafa2d7b285912c64cefa90a1b2656a3d6878)
M +2 -3 plugins/sms/smsplugin.cpp
https://invent.kde.org/network/kdeconnect-kde/-/commit/0d9995385fe5521ab782de6753a0995e12ad1910
diff --git a/plugins/sms/smsplugin.cpp b/plugins/sms/smsplugin.cpp
index 4711b3885..fa73d3b7c 100644
--- a/plugins/sms/smsplugin.cpp
+++ b/plugins/sms/smsplugin.cpp
@@ -188,9 +188,8 @@ void SmsPlugin::getAttachment(const qint64 &partID, const QString &uniqueIdentif
Attachment SmsPlugin::createAttachmentFromUrl(const QString &url)
{
QFile file(url);
- file.open(QIODevice::ReadOnly);
-
- if (!file.exists()) {
+ if (!file.open(QIODevice::ReadOnly)) {
+ qCWarning(KDECONNECT_PLUGIN_SMS) << "Could not read the attachment" << url << file.errorString();
return Attachment();
}