[network/kdeconnect-kde] 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 3a6bafa2d7b285912c64cefa90a1b2656a3d6878 by Albert Vaca Cintora, on behalf of Méven Car.
Committed on 28/07/2026 at 05:14.
Pushed by albertvaka into branch 'master'.

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.

M  +2    -3    plugins/sms/smsplugin.cpp

https://invent.kde.org/network/kdeconnect-kde/-/commit/3a6bafa2d7b285912c64cefa90a1b2656a3d6878

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();
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.