Delete partially downloaded file when transfer is canceled locally
This commit is contained in:
parent
6c6cd751ba
commit
6fb67d0261
2 changed files with 13 additions and 4 deletions
|
@ -130,9 +130,7 @@ void FileTransferJob::transferFinished()
|
||||||
} else {
|
} else {
|
||||||
qCDebug(KDECONNECT_CORE) << "Received incomplete file ("<< m_written << "/" << m_size << "bytes ), deleting";
|
qCDebug(KDECONNECT_CORE) << "Received incomplete file ("<< m_written << "/" << m_size << "bytes ), deleting";
|
||||||
|
|
||||||
if (m_destination.isLocalFile() && QFile::exists(m_destination.toLocalFile())) {
|
deleteDestinationFile();
|
||||||
QFile::remove(m_destination.toLocalFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
setError(3);
|
setError(3);
|
||||||
setErrorText(i18n("Received incomplete file from: %1", m_from));
|
setErrorText(i18n("Received incomplete file from: %1", m_from));
|
||||||
|
@ -140,6 +138,13 @@ void FileTransferJob::transferFinished()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileTransferJob::deleteDestinationFile()
|
||||||
|
{
|
||||||
|
if (m_destination.isLocalFile() && QFile::exists(m_destination.toLocalFile())) {
|
||||||
|
QFile::remove(m_destination.toLocalFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FileTransferJob::doKill()
|
bool FileTransferJob::doKill()
|
||||||
{
|
{
|
||||||
if (m_reply) {
|
if (m_reply) {
|
||||||
|
@ -148,5 +153,8 @@ bool FileTransferJob::doKill()
|
||||||
if (m_origin) {
|
if (m_origin) {
|
||||||
m_origin->close();
|
m_origin->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteDestinationFile();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ private:
|
||||||
void startTransfer();
|
void startTransfer();
|
||||||
void transferFailed(QNetworkReply::NetworkError error);
|
void transferFailed(QNetworkReply::NetworkError error);
|
||||||
void transferFinished();
|
void transferFinished();
|
||||||
|
void deleteDestinationFile();
|
||||||
|
|
||||||
QSharedPointer<QIODevice> m_origin;
|
QSharedPointer<QIODevice> m_origin;
|
||||||
QNetworkReply* m_reply;
|
QNetworkReply* m_reply;
|
||||||
|
|
Loading…
Reference in a new issue