[OAuth] Fix lock

This commit is contained in:
Hannah von Reth 2020-01-29 16:05:27 +01:00 committed by Hannah von Reth
parent 29b1eaa2fa
commit 8202eb91b2
3 changed files with 19 additions and 2 deletions

View File

@ -125,8 +125,18 @@ QNetworkReply *AbstractNetworkJob::addTimer(QNetworkReply *reply)
return reply;
}
bool AbstractNetworkJob::retryAble() const
{
return _retryAble;
}
void AbstractNetworkJob::setRetryAble(bool retryAble)
{
_retryAble = retryAble;
}
QNetworkReply *AbstractNetworkJob::sendRequest(const QByteArray &verb, const QUrl &url,
QNetworkRequest req, QIODevice *requestBody)
QNetworkRequest req, QIODevice *requestBody)
{
auto reply = _account->sendRawRequest(verb, url, req, requestBody);
_requestBody = requestBody;
@ -196,7 +206,7 @@ void AbstractNetworkJob::slotFinished()
if (_reply->error() != QNetworkReply::NoError) {
if (_account->credentials()->retryIfNeeded(this))
if (retryAble() && _account->credentials()->retryIfNeeded(this))
return;
if (!_ignoreCredentialFailure || _reply->error() != QNetworkReply::AuthenticationRequiredError) {

View File

@ -98,6 +98,10 @@ public:
*/
static int httpTimeout;
/** whether or noth this job can be retried */
bool retryAble() const;
void setRetryAble(bool retryAble);
public slots:
void setTimeout(qint64 msec);
void resetTimeout();
@ -202,6 +206,8 @@ private:
//
// Reparented to the currently running QNetworkReply.
QPointer<QIODevice> _requestBody;
bool _retryAble = true;
};
/**

View File

@ -249,6 +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);
return job;
}