Handle transfer job being canceled

Set KilledJobError to indicate it was canceled by the user
to avoid a bogus "finished" notification.

Sadly, fileTransferCanceled has been removed from libQuotient
so this lambda botch checking transfer status needs to be done.
This commit is contained in:
Kai Uwe Broulik
2025-01-03 13:55:20 +01:00
parent c454a4942e
commit 7b7f4d264c
3 changed files with 30 additions and 2 deletions

View File

@@ -256,7 +256,14 @@ QCoro::Task<void> NeoChatRoom::doUploadFile(QUrl url, QString body)
auto job = new FileTransferPseudoJob(FileTransferPseudoJob::Upload, url.toLocalFile(), txnId);
connect(this, &Room::fileTransferProgress, job, &FileTransferPseudoJob::fileTransferProgress);
connect(this, &Room::fileTransferCompleted, job, &FileTransferPseudoJob::fileTransferCompleted);
connect(this, &Room::fileTransferFailed, job, &FileTransferPseudoJob::fileTransferFailed);
connect(this, &Room::fileTransferFailed, job, [this, job, txnId] {
auto info = fileTransferInfo(txnId);
if (info.status == FileTransferInfo::Cancelled) {
job->fileTransferCanceled(txnId);
} else {
job->fileTransferFailed(txnId);
}
});
KIO::getJobTracker()->registerJob(job);
job->start();
#endif
@@ -1511,7 +1518,14 @@ void NeoChatRoom::download(const QString &eventId, const QUrl &localFilename)
auto job = new FileTransferPseudoJob(FileTransferPseudoJob::Download, localFilename.toLocalFile(), eventId);
connect(this, &Room::fileTransferProgress, job, &FileTransferPseudoJob::fileTransferProgress);
connect(this, &Room::fileTransferCompleted, job, &FileTransferPseudoJob::fileTransferCompleted);
connect(this, &Room::fileTransferFailed, job, &FileTransferPseudoJob::fileTransferFailed);
connect(this, &Room::fileTransferFailed, job, [this, job, eventId] {
auto info = fileTransferInfo(eventId);
if (info.status == FileTransferInfo::Cancelled) {
job->fileTransferCanceled(eventId);
} else {
job->fileTransferFailed(eventId);
}
});
KIO::getJobTracker()->registerJob(job);
job->start();
#endif