diff --git a/src/core/copyjob.h b/src/core/copyjob.h --- a/src/core/copyjob.h +++ b/src/core/copyjob.h @@ -94,6 +94,12 @@ */ QUrl destUrl() const; + /** + * Returns the current file destination URL. + * @return the current file destination URL + */ + QUrl currentDestUrl() const; + /** * By default the permissions of the copied files will be those of the source files. * diff --git a/src/core/copyjob.cpp b/src/core/copyjob.cpp --- a/src/core/copyjob.cpp +++ b/src/core/copyjob.cpp @@ -316,6 +316,11 @@ return d_func()->m_dest; } +QUrl CopyJob::currentDestUrl() const +{ + return d_func()->m_currentDestURL; +} + void CopyJobPrivate::slotStart() { Q_Q(CopyJob); diff --git a/src/widgets/dropjob.cpp b/src/widgets/dropjob.cpp --- a/src/widgets/dropjob.cpp +++ b/src/widgets/dropjob.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -555,9 +556,17 @@ void DropJob::slotResult(KJob *job) { - if (job->error()) { - KIO::Job::slotResult(job); // will set the error and emit result(this) - return; + int jobError = job->error(); + if (jobError) { + if (jobError == KIO::ERR_USER_CANCELED || jobError == KIO::ERR_DISK_FULL) { + // Must remove last file that was not finished moving/copying + KIO::CopyJob *copyJob = qobject_cast(job); + this->addSubjob(KIO::del(copyJob->currentDestUrl(), JobFlag::HideProgressInfo)); + return; + } else { + KIO::Job::slotResult(job); // will set the error and emit result(this) + return; + } } removeSubjob(job); emitResult(); diff --git a/src/widgets/pastejob.cpp b/src/widgets/pastejob.cpp --- a/src/widgets/pastejob.cpp +++ b/src/widgets/pastejob.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -85,10 +86,17 @@ void PasteJob::slotResult(KJob *job) { - if (job->error()) { + int jobError = job->error(); + if (jobError) { + if (jobError == KIO::ERR_USER_CANCELED || jobError == KIO::ERR_DISK_FULL) { + // Must remove last file that was not finished moving/copying + KIO::CopyJob *copyJob = qobject_cast(job); + this->addSubjob(KIO::del(copyJob->currentDestUrl(), JobFlag::HideProgressInfo)); + } KIO::Job::slotResult(job); // will set the error and emit result(this) return; } + KIO::SimpleJob *simpleJob = qobject_cast(job); if (simpleJob) { emit itemCreated(simpleJob->url());