Skip to content

Commit

Permalink
AbstractNetworkJob: move the httpTimeout from the propagator to the n…
Browse files Browse the repository at this point in the history
…etwork job

Remove one dependency from the config file for the sync engine.
Part of issue #6213
  • Loading branch information
ogoffart committed Dec 5, 2017
1 parent 1acc5f3 commit a46dcef
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ Application::Application(int &argc, char **argv)
excludes.addExcludeFilePath(cfg.excludeFile(ConfigFile::UserScope));
excludes.reloadExcludes();

// The timeout is initialized with an environment variable, if not, override with the value from the config
if (!AbstractNetworkJob::httpTimeout)
AbstractNetworkJob::httpTimeout = cfg.timeout();

_folderManager.reset(new FolderMan);

connect(this, &SharedTools::QtSingleApplication::messageReceived, this, &Application::slotParseMessage);
Expand Down
5 changes: 4 additions & 1 deletion src/libsync/abstractnetworkjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace OCC {

Q_LOGGING_CATEGORY(lcNetworkJob, "sync.networkjob", QtInfoMsg)

// If not set, it is overwritten by the Application constructor with the value from the config
int AbstractNetworkJob::httpTimeout = qEnvironmentVariableIntValue("OWNCLOUD_TIMEOUT");

AbstractNetworkJob::AbstractNetworkJob(AccountPtr account, const QString &path, QObject *parent)
: QObject(parent)
, _timedout(false)
Expand All @@ -51,7 +54,7 @@ AbstractNetworkJob::AbstractNetworkJob(AccountPtr account, const QString &path,
, _redirectCount(0)
{
_timer.setSingleShot(true);
_timer.setInterval(OwncloudPropagator::httpTimeout() * 1000); // default to 5 minutes.
_timer.setInterval((httpTimeout ? httpTimeout : 300) * 1000); // default to 5 minutes.
connect(&_timer, &QTimer::timeout, this, &AbstractNetworkJob::slotTimeout);

connect(this, &AbstractNetworkJob::networkActivity, this, &AbstractNetworkJob::resetTimeout);
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/abstractnetworkjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class OWNCLOUDSYNC_EXPORT AbstractNetworkJob : public QObject
*/
QString errorStringParsingBody(QByteArray *body = 0);

/** static variable the HTTP timeout (in seconds) */
static int httpTimeout;

public slots:
void setTimeout(qint64 msec);
void resetTimeout();
Expand Down
14 changes: 0 additions & 14 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "propagateremotemove.h"
#include "propagateremotemkdir.h"
#include "propagatorjobs.h"
#include "configfile.h"
#include "common/utility.h"
#include "account.h"
#include "common/asserts.h"
Expand Down Expand Up @@ -554,19 +553,6 @@ bool OwncloudPropagator::isInSharedDirectory(const QString &file)
return re;
}

int OwncloudPropagator::httpTimeout()
{
static int timeout = 0;
if (!timeout) {
timeout = qgetenv("OWNCLOUD_TIMEOUT").toUInt();
if (timeout == 0) {
ConfigFile cfg;
timeout = cfg.timeout();
}
}
return timeout;
}

bool OwncloudPropagator::localFileNameClash(const QString &relFile)
{
bool re = false;
Expand Down
3 changes: 0 additions & 3 deletions src/libsync/owncloudpropagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,6 @@ class OwncloudPropagator : public QObject
}
}

// timeout in seconds
static int httpTimeout();

AccountPtr account() const;

enum DiskSpaceResult {
Expand Down

0 comments on commit a46dcef

Please sign in to comment.