[OAuth] Fix lock

This commit is contained in:
Hannah von Reth 2020-02-05 16:11:22 +01:00 committed by Hannah von Reth
parent 8202eb91b2
commit c0b3e6d9d4
3 changed files with 10 additions and 11 deletions

View File

@ -125,14 +125,14 @@ QNetworkReply *AbstractNetworkJob::addTimer(QNetworkReply *reply)
return reply;
}
bool AbstractNetworkJob::retryAble() const
bool AbstractNetworkJob::isAuthenticationJob() const
{
return _retryAble;
return _isAuthenticationJob;
}
void AbstractNetworkJob::setRetryAble(bool retryAble)
void AbstractNetworkJob::setAuthenticationJob(bool b)
{
_retryAble = retryAble;
_isAuthenticationJob = b;
}
QNetworkReply *AbstractNetworkJob::sendRequest(const QByteArray &verb, const QUrl &url,
@ -205,8 +205,7 @@ void AbstractNetworkJob::slotFinished()
}
if (_reply->error() != QNetworkReply::NoError) {
if (retryAble() && _account->credentials()->retryIfNeeded(this))
if (!isAuthenticationJob() && _account->credentials()->retryIfNeeded(this))
return;
if (!_ignoreCredentialFailure || _reply->error() != QNetworkReply::AuthenticationRequiredError) {

View File

@ -98,9 +98,9 @@ public:
*/
static int httpTimeout;
/** whether or noth this job can be retried */
bool retryAble() const;
void setRetryAble(bool retryAble);
/** whether or noth this job should be restarted after authentication */
bool isAuthenticationJob() const;
void setAuthenticationJob(bool b);
public slots:
void setTimeout(qint64 msec);
@ -207,7 +207,7 @@ private:
// Reparented to the currently running QNetworkReply.
QPointer<QIODevice> _requestBody;
bool _retryAble = true;
bool _isAuthenticationJob = false;
};
/**

View File

@ -249,7 +249,7 @@ SimpleNetworkJob *OAuth::postTokenRequest(const QList<QPair<QString, QString>> &
auto job = _account->sendRequest("POST", requestTokenUrl, req, requestBody);
job->setTimeout(qMin(30 * 1000ll, job->timeoutMsec()));
job->setRetryAble(false);
job->setAuthenticationJob(true);
return job;
}