diff --git a/core/filetransferjob.cpp b/core/filetransferjob.cpp index b9591a83c..9a92a917f 100644 --- a/core/filetransferjob.cpp +++ b/core/filetransferjob.cpp @@ -130,16 +130,21 @@ void FileTransferJob::transferFinished() } else { qCDebug(KDECONNECT_CORE) << "Received incomplete file ("<< m_written << "/" << m_size << "bytes ), deleting"; - if (m_destination.isLocalFile() && QFile::exists(m_destination.toLocalFile())) { - QFile::remove(m_destination.toLocalFile()); - } - + deleteDestinationFile(); + setError(3); setErrorText(i18n("Received incomplete file from: %1", m_from)); emitResult(); } } +void FileTransferJob::deleteDestinationFile() +{ + if (m_destination.isLocalFile() && QFile::exists(m_destination.toLocalFile())) { + QFile::remove(m_destination.toLocalFile()); + } +} + bool FileTransferJob::doKill() { if (m_reply) { @@ -148,5 +153,8 @@ bool FileTransferJob::doKill() if (m_origin) { m_origin->close(); } + + deleteDestinationFile(); + return true; } diff --git a/core/filetransferjob.h b/core/filetransferjob.h index fc2cefaf8..09bc24f96 100644 --- a/core/filetransferjob.h +++ b/core/filetransferjob.h @@ -64,6 +64,7 @@ private: void startTransfer(); void transferFailed(QNetworkReply::NetworkError error); void transferFinished(); + void deleteDestinationFile(); QSharedPointer m_origin; QNetworkReply* m_reply;