diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 934e23ecb11..ceaf30a83d0 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -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); diff --git a/src/libsync/abstractnetworkjob.cpp b/src/libsync/abstractnetworkjob.cpp index 78d5b9ab6b9..0149bec4252 100644 --- a/src/libsync/abstractnetworkjob.cpp +++ b/src/libsync/abstractnetworkjob.cpp @@ -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) @@ -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); diff --git a/src/libsync/abstractnetworkjob.h b/src/libsync/abstractnetworkjob.h index ec9a31addcc..5a650c07a57 100644 --- a/src/libsync/abstractnetworkjob.h +++ b/src/libsync/abstractnetworkjob.h @@ -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(); diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index d90ae8af77e..e1d081141aa 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -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" @@ -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; diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index efc7c01dda2..062b3825e5c 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -464,9 +464,6 @@ class OwncloudPropagator : public QObject } } - // timeout in seconds - static int httpTimeout(); - AccountPtr account() const; enum DiskSpaceResult {