Skip to content

Commit

Permalink
disable our code for network timeout
Browse files Browse the repository at this point in the history
seems we have an issue with Windows and QTimer instances used to detect
network timeout

workaround, find cause of #7184

Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien authored and backportbot[bot] committed Sep 26, 2024
1 parent abbbc29 commit 14aef72
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libsync/abstractnetworkjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/abstractnetworkjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class OWNCLOUDSYNC_EXPORT AbstractNetworkJob : public QObject
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; }
Expand Down
2 changes: 2 additions & 0 deletions test/testchunkingng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions test/testremotediscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 14aef72

Please sign in to comment.