From 716a6a462efc2a57945ab5efd6065772ddb1df09 2017-07-19 12:39:11 From: mperrinel Date: 2017-07-19 12:39:11 Subject: [PATCH] Add implementation of abort impact on Amda plugin --- diff --git a/plugins/amda/src/AmdaProvider.cpp b/plugins/amda/src/AmdaProvider.cpp index 4ae61f4..d9392b0 100644 --- a/plugins/amda/src/AmdaProvider.cpp +++ b/plugins/amda/src/AmdaProvider.cpp @@ -98,38 +98,45 @@ void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime, const = [this, dateTime, tempFile, token](QNetworkReply *reply, QUuid dataId) noexcept { Q_UNUSED(dataId); - if (tempFile) { - auto replyReadAll = reply->readAll(); - if (!replyReadAll.isEmpty()) { - tempFile->write(replyReadAll); - } - tempFile->close(); - - // Parse results file - if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) { - emit dataProvided(token, dataSeries, dateTime); - } - else { - /// @todo ALX : debug + // Don't do anything if the reply was abort + if (reply->error() != QNetworkReply::OperationCanceledError) { + + if (tempFile) { + auto replyReadAll = reply->readAll(); + if (!replyReadAll.isEmpty()) { + tempFile->write(replyReadAll); + } + tempFile->close(); + + // Parse results file + if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) { + emit dataProvided(token, dataSeries, dateTime); + } + else { + /// @todo ALX : debug + } } } - }; - auto httpFinishedLambda = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, - QUuid dataId) noexcept { + auto httpFinishedLambda + = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept { - auto downloadFileUrl = QUrl{QString{reply->readAll()}}; + // Don't do anything if the reply was abort + if (reply->error() != QNetworkReply::OperationCanceledError) { + auto downloadFileUrl = QUrl{QString{reply->readAll()}}; - // Executes request for downloading file // + // Executes request for downloading file // - // Creates destination file - if (tempFile->open()) { - // Executes request - emit requestConstructed(QNetworkRequest{downloadFileUrl}, dataId, httpDownloadFinished); - } - }; + // Creates destination file + if (tempFile->open()) { + // Executes request + emit requestConstructed(QNetworkRequest{downloadFileUrl}, dataId, + httpDownloadFinished); + } + } + }; // //////////////// // // Executes request //