[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:29:54 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=f011191

The following commit has been merged in the master branch:
commit f011191eca23e0197d0f0b6ba15772c0b3fa79fb
Author: Aleix Pol <aleixpol at kde.org>
Date:   Wed Jun 22 12:42:51 2016 +0200

    Fix few issues in FileTransferJob
    
    Handle errors from different endpoints
    Don't ::startTransfer when we find a colliding file
---
 core/filetransferjob.cpp | 27 +++++++++++++++++----------
 core/filetransferjob.h   |  1 +
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/core/filetransferjob.cpp b/core/filetransferjob.cpp
index c8f0909..0c5dd84 100644
--- a/core/filetransferjob.cpp
+++ b/core/filetransferjob.cpp
@@ -62,13 +62,14 @@ void FileTransferJob::start()
 void FileTransferJob::doStart()
 {
     description(this, i18n("Receiving file over KDE Connect"),
-        QPair<QString, QString>(i18nc("File transfer origin", "From"), mFrom)
+        { i18nc("File transfer origin", "From"), mFrom }
     );
 
     if (mDestination.isLocalFile() && QFile::exists(mDestination.toLocalFile())) {
         setError(2);
         setErrorText(i18n("Filename already present"));
         emitResult();
+        return;
     }
 
     startTransfer();
@@ -79,8 +80,8 @@ void FileTransferJob::startTransfer()
     setProcessedAmount(Bytes, 0);
     mTime = QTime::currentTime();
     description(this, i18n("Receiving file over KDE Connect"),
-                        QPair<QString, QString>(i18nc("File transfer origin", "From"), mFrom),
-                        QPair<QString, QString>(i18nc("File transfer destination", "To"), mDestination.toLocalFile()));
+                        { i18nc("File transfer origin", "From"), mFrom },
+                        { i18nc("File transfer destination", "To"), mDestination.toLocalFile() });
 
     QNetworkRequest req(mDestination);
     req.setHeader(QNetworkRequest::ContentLengthHeader, totalAmount(Bytes));
@@ -90,19 +91,25 @@ void FileTransferJob::startTransfer()
         setProcessedAmount(Bytes, bytesSent);
         emitSpeed(bytesSent/mTime.elapsed());
     });
+    connect(mReply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
+            this, &FileTransferJob::transferFailed);
     connect(mReply, &QNetworkReply::finished, this, &FileTransferJob::transferFinished);
 }
 
+void FileTransferJob::transferFailed(QNetworkReply::NetworkError error)
+{
+    qCDebug(KDECONNECT_CORE) << "Couldn't transfer the file successfully" << error << mReply->errorString();
+    setError(error);
+    setErrorText(i18n("Received incomplete file: %1", mReply->errorString()));
+    emitResult();
+
+    mReply->close();
+}
+
 void FileTransferJob::transferFinished()
 {
     //TODO: MD5-check the file
-    if (mReply->error()) {
-        qCDebug(KDECONNECT_CORE) << "Couldn't transfer the file successfully" << mReply->errorString();
-        setError(mReply->error());
-        setErrorText(i18n("Received incomplete file: %1", mReply->errorString()));
-    } else {
-        qCDebug(KDECONNECT_CORE) << "Finished transfer" << mDestination;
-    }
+    qCDebug(KDECONNECT_CORE) << "Finished transfer" << mDestination;
 
     emitResult();
 }
diff --git a/core/filetransferjob.h b/core/filetransferjob.h
index a4ea1ee..2021034 100644
--- a/core/filetransferjob.h
+++ b/core/filetransferjob.h
@@ -65,6 +65,7 @@ protected:
 
 private:
     void startTransfer();
+    void transferFailed(QNetworkReply::NetworkError error);
     void transferFinished();
 
     QSharedPointer<QIODevice> mOrigin;

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list