Skip to content

Commit

Permalink
Merge pull request #7218 from nextcloud/backport/7200/stable-3.14
Browse files Browse the repository at this point in the history
[stable-3.14] disable our code for network timeout
  • Loading branch information
mgallien committed Sep 26, 2024
2 parents abbbc29 + 14aef72 commit 4db6cf0
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 4db6cf0

Please sign in to comment.