mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
NetworkJobs: Propagator jobs keep others from expiring. #2155
In some owncloud server setups multiple concurrent connections for the same session are not supported: owncloud/core#11153 This causes issues with multiple uploads and downloads. A usual symptom is the quota job failing and the sync aborting. This workaround lets activity on the propagator's GET and PUT jobs reset the timeout of all network jobs. That way, queries like the quota job would not time out while a large up/download is in progress.
This commit is contained in:
parent
c85b6193d5
commit
2eec85a97c
@ -154,8 +154,10 @@ public:
|
||||
QNetworkAccessManager* networkAccessManager();
|
||||
|
||||
QuotaInfo *quotaInfo();
|
||||
|
||||
signals:
|
||||
void stateChanged(int state);
|
||||
void propagatorNetworkActivity();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void slotHandleErrors(QNetworkReply*,QList<QSslError>);
|
||||
|
||||
@ -50,6 +50,15 @@ AbstractNetworkJob::AbstractNetworkJob(Account *account, const QString &path, QO
|
||||
_timer.setSingleShot(true);
|
||||
_timer.setInterval(10*1000); // default to 10 seconds.
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
|
||||
|
||||
connect(this, SIGNAL(networkActivity()), SLOT(resetTimeout()));
|
||||
|
||||
// Network activity on the propagator jobs (GET/PUT) keeps all requests alive.
|
||||
// This is a workaround for OC instances which only support one
|
||||
// parallel up and download
|
||||
if (_account) {
|
||||
connect(_account, SIGNAL(propagatorNetworkActivity()), SLOT(resetTimeout()));
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractNetworkJob::setReply(QNetworkReply *reply)
|
||||
@ -80,11 +89,6 @@ void AbstractNetworkJob::setIgnoreCredentialFailure(bool ignore)
|
||||
_ignoreCredentialFailure = ignore;
|
||||
}
|
||||
|
||||
void AbstractNetworkJob::setAccount(Account *account)
|
||||
{
|
||||
_account = account;
|
||||
}
|
||||
|
||||
void AbstractNetworkJob::setPath(const QString &path)
|
||||
{
|
||||
_path = path;
|
||||
@ -93,6 +97,8 @@ void AbstractNetworkJob::setPath(const QString &path)
|
||||
void AbstractNetworkJob::setupConnections(QNetworkReply *reply)
|
||||
{
|
||||
connect(reply, SIGNAL(finished()), SLOT(slotFinished()));
|
||||
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(networkActivity()));
|
||||
connect(reply, SIGNAL(uploadProgress(qint64,qint64)), SIGNAL(networkActivity()));
|
||||
}
|
||||
|
||||
QNetworkReply* AbstractNetworkJob::addTimer(QNetworkReply *reply)
|
||||
@ -179,9 +185,11 @@ QString AbstractNetworkJob::responseTimestamp()
|
||||
return _responseTimestamp;
|
||||
}
|
||||
|
||||
AbstractNetworkJob::~AbstractNetworkJob() {
|
||||
if (_reply)
|
||||
AbstractNetworkJob::~AbstractNetworkJob()
|
||||
{
|
||||
if (_reply) {
|
||||
_reply->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractNetworkJob::start()
|
||||
|
||||
@ -55,15 +55,14 @@ public:
|
||||
|
||||
virtual void start();
|
||||
|
||||
void setAccount(Account *account);
|
||||
Account* account() const { return _account; }
|
||||
|
||||
void setPath(const QString &path);
|
||||
QString path() const { return _path; }
|
||||
|
||||
void setReply(QNetworkReply *reply);
|
||||
QNetworkReply* reply() const { return _reply; }
|
||||
|
||||
|
||||
void setIgnoreCredentialFailure(bool ignore);
|
||||
bool ignoreCredentialFailure() const { return _ignoreCredentialFailure; }
|
||||
|
||||
@ -75,6 +74,7 @@ public slots:
|
||||
void resetTimeout();
|
||||
signals:
|
||||
void networkError(QNetworkReply *reply);
|
||||
void networkActivity();
|
||||
protected:
|
||||
void setupConnections(QNetworkReply *reply);
|
||||
QNetworkReply* davRequest(const QByteArray& verb, const QString &relPath,
|
||||
|
||||
@ -94,7 +94,7 @@ void PUTFileJob::start() {
|
||||
}
|
||||
|
||||
connect(reply(), SIGNAL(uploadProgress(qint64,qint64)), this, SIGNAL(uploadProgress(qint64,qint64)));
|
||||
connect(reply(), SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(resetTimeout()));
|
||||
connect(this, SIGNAL(networkActivity()), account(), SIGNAL(propagatorNetworkActivity()));
|
||||
|
||||
AbstractNetworkJob::start();
|
||||
}
|
||||
@ -469,6 +469,7 @@ void GETFileJob::start() {
|
||||
connect(reply(), SIGNAL(metaDataChanged()), this, SLOT(slotMetaDataChanged()));
|
||||
connect(reply(), SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
|
||||
connect(reply(), SIGNAL(downloadProgress(qint64,qint64)), this, SIGNAL(downloadProgress(qint64,qint64)));
|
||||
connect(this, SIGNAL(networkActivity()), account(), SIGNAL(propagatorNetworkActivity()));
|
||||
|
||||
AbstractNetworkJob::start();
|
||||
}
|
||||
@ -556,7 +557,6 @@ void GETFileJob::slotReadyRead()
|
||||
return;
|
||||
}
|
||||
}
|
||||
resetTimeout();
|
||||
}
|
||||
|
||||
void GETFileJob::slotTimeout()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user