From 14aef728b40afd64610dd5c11e39094319ad4dd7 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 25 Sep 2024 11:41:16 +0200 Subject: [PATCH] disable our code for network timeout seems we have an issue with Windows and QTimer instances used to detect network timeout workaround, find cause of https://github.com/nextcloud/desktop/issues/7184 Signed-off-by: Matthieu Gallien --- src/libsync/abstractnetworkjob.cpp | 7 ++++++- src/libsync/abstractnetworkjob.h | 2 ++ test/testchunkingng.cpp | 2 ++ test/testremotediscovery.cpp | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libsync/abstractnetworkjob.cpp b/src/libsync/abstractnetworkjob.cpp index 5e9df7067..f08b13582 100644 --- a/src/libsync/abstractnetworkjob.cpp +++ b/src/libsync/abstractnetworkjob.cpp @@ -46,6 +46,7 @@ Q_LOGGING_CATEGORY(lcNetworkJob, "nextcloud.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"); +bool AbstractNetworkJob::enableTimeout = false; AbstractNetworkJob::AbstractNetworkJob(const AccountPtr &account, const QString &path, QObject *parent) : QObject(parent) @@ -57,7 +58,6 @@ AbstractNetworkJob::AbstractNetworkJob(const AccountPtr &account, const QString ASSERT(account != parent); _timer.setSingleShot(true); - _timer.setTimerType(Qt::VeryCoarseTimer); _timer.setInterval((httpTimeout ? httpTimeout : 300) * 1000); // default to 5 minutes. connect(&_timer, &QTimer::timeout, this, &AbstractNetworkJob::slotTimeout); @@ -367,6 +367,11 @@ void AbstractNetworkJob::start() void AbstractNetworkJob::slotTimeout() { + // TODO: workaround, find cause of https://github.com/nextcloud/desktop/issues/7184 + if (!AbstractNetworkJob::enableTimeout) { + return; + } + _timedout = true; qCWarning(lcNetworkJob) << "Network job timeout" << (reply() ? reply()->request().url() : path()); onTimedOut(); diff --git a/src/libsync/abstractnetworkjob.h b/src/libsync/abstractnetworkjob.h index 814f0e846..aefcfb630 100644 --- a/src/libsync/abstractnetworkjob.h +++ b/src/libsync/abstractnetworkjob.h @@ -45,6 +45,8 @@ public: explicit AbstractNetworkJob(const AccountPtr &account, const QString &path, QObject *parent = nullptr); ~AbstractNetworkJob() override; + static bool enableTimeout; + virtual void start(); [[nodiscard]] AccountPtr account() const { return _account; } diff --git a/test/testchunkingng.cpp b/test/testchunkingng.cpp index 8c643511e..8ec79d34a 100644 --- a/test/testchunkingng.cpp +++ b/test/testchunkingng.cpp @@ -60,6 +60,8 @@ class TestChunkingNG : public QObject private slots: void initTestCase() { + AbstractNetworkJob::enableTimeout = true; + OCC::Logger::instance()->setLogFlush(true); OCC::Logger::instance()->setLogDebug(true); diff --git a/test/testremotediscovery.cpp b/test/testremotediscovery.cpp index cd5bec231..a688b8d92 100644 --- a/test/testremotediscovery.cpp +++ b/test/testremotediscovery.cpp @@ -50,6 +50,8 @@ class TestRemoteDiscovery : public QObject private slots: void initTestCase() { + AbstractNetworkJob::enableTimeout = true; + OCC::Logger::instance()->setLogFlush(true); OCC::Logger::instance()->setLogDebug(true);