|
|
@ -221,15 +221,15 @@ Net::DownloadHandler *Net::DownloadManager::download(const DownloadRequest &down |
|
|
|
m_waitingJobs[id].removeOne(downloadHandler); |
|
|
|
m_waitingJobs[id].removeOne(downloadHandler); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (!isSequentialService || !m_busyServices.contains(id)) { |
|
|
|
if (isSequentialService && m_busyServices.contains(id)) { |
|
|
|
|
|
|
|
m_waitingJobs[id].enqueue(downloadHandler); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
qDebug("Downloading %s...", qUtf8Printable(downloadRequest.url())); |
|
|
|
qDebug("Downloading %s...", qUtf8Printable(downloadRequest.url())); |
|
|
|
if (isSequentialService) |
|
|
|
if (isSequentialService) |
|
|
|
m_busyServices.insert(id); |
|
|
|
m_busyServices.insert(id); |
|
|
|
downloadHandler->assignNetworkReply(m_networkManager.get(request)); |
|
|
|
downloadHandler->assignNetworkReply(m_networkManager.get(request)); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
m_waitingJobs[id].enqueue(downloadHandler); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return downloadHandler; |
|
|
|
return downloadHandler; |
|
|
|
} |
|
|
|
} |
|
|
@ -308,9 +308,13 @@ void Net::DownloadManager::applyProxySettings() |
|
|
|
|
|
|
|
|
|
|
|
void Net::DownloadManager::handleReplyFinished(const QNetworkReply *reply) |
|
|
|
void Net::DownloadManager::handleReplyFinished(const QNetworkReply *reply) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const ServiceID id = ServiceID::fromURL(reply->url()); |
|
|
|
// QNetworkReply::url() may be different from that of the original request
|
|
|
|
|
|
|
|
// so we need QNetworkRequest::url() to properly process Sequential Services
|
|
|
|
|
|
|
|
// in the case when the redirection occurred.
|
|
|
|
|
|
|
|
const ServiceID id = ServiceID::fromURL(reply->request().url()); |
|
|
|
const auto waitingJobsIter = m_waitingJobs.find(id); |
|
|
|
const auto waitingJobsIter = m_waitingJobs.find(id); |
|
|
|
if ((waitingJobsIter == m_waitingJobs.end()) || waitingJobsIter.value().isEmpty()) { |
|
|
|
if ((waitingJobsIter == m_waitingJobs.end()) || waitingJobsIter.value().isEmpty()) { |
|
|
|
|
|
|
|
// No more waiting jobs for given ServiceID
|
|
|
|
m_busyServices.remove(id); |
|
|
|
m_busyServices.remove(id); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -437,13 +441,12 @@ namespace |
|
|
|
|
|
|
|
|
|
|
|
void DownloadHandlerImpl::processFinishedDownload() |
|
|
|
void DownloadHandlerImpl::processFinishedDownload() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QString url = m_reply->url().toString(); |
|
|
|
qDebug("Download finished: %s", qUtf8Printable(url())); |
|
|
|
qDebug("Download finished: %s", qUtf8Printable(url)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if the request was successful
|
|
|
|
// Check if the request was successful
|
|
|
|
if (m_reply->error() != QNetworkReply::NoError) { |
|
|
|
if (m_reply->error() != QNetworkReply::NoError) { |
|
|
|
// Failure
|
|
|
|
// Failure
|
|
|
|
qDebug("Download failure (%s), reason: %s", qUtf8Printable(url), qUtf8Printable(errorCodeToString(m_reply->error()))); |
|
|
|
qDebug("Download failure (%s), reason: %s", qUtf8Printable(url()), qUtf8Printable(errorCodeToString(m_reply->error()))); |
|
|
|
setError(errorCodeToString(m_reply->error())); |
|
|
|
setError(errorCodeToString(m_reply->error())); |
|
|
|
finish(); |
|
|
|
finish(); |
|
|
|
return; |
|
|
|
return; |
|
|
|