From 572e82cec0c290563ede062a0b46cc0225a2c82a Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 18 Feb 2024 00:53:28 +0100 Subject: [PATCH] Fix resuming devs when network not metered anymore after 57d47de7 --- syncthingconnector/syncthingconnection.cpp | 4 ++-- syncthingconnector/syncthingconnection.h | 2 +- syncthingconnector/syncthingconnection_requests.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/syncthingconnector/syncthingconnection.cpp b/syncthingconnector/syncthingconnection.cpp index f5144ae..38cfcda 100644 --- a/syncthingconnector/syncthingconnection.cpp +++ b/syncthingconnector/syncthingconnection.cpp @@ -297,10 +297,10 @@ void SyncthingConnection::handleMeteredConnection() } } if (hasDevicesToPause) { - pauseDevice(m_devsPausedDueToMeteredConnection); + pauseResumeDevice(m_devsPausedDueToMeteredConnection, true, true); } } else { - resumeDevice(m_devsPausedDueToMeteredConnection); + pauseResumeDevice(m_devsPausedDueToMeteredConnection, false, true); m_devsPausedDueToMeteredConnection.clear(); } #endif diff --git a/syncthingconnector/syncthingconnection.h b/syncthingconnector/syncthingconnection.h index 337e845..c03e6a6 100644 --- a/syncthingconnector/syncthingconnection.h +++ b/syncthingconnector/syncthingconnection.h @@ -365,7 +365,7 @@ private: Reply prepareReply(QNetworkReply *&expectedReply, bool readData = true, bool handleAborting = true); Reply prepareReply(QList &expectedReplies, bool readData = true, bool handleAborting = true); Reply handleReply(QNetworkReply *reply, bool readData, bool handleAborting); - bool pauseResumeDevice(const QStringList &devIds, bool paused); + bool pauseResumeDevice(const QStringList &devIds, bool paused, bool dueToMetered = false); bool pauseResumeDirectory(const QStringList &dirIds, bool paused); SyncthingDir *addDirInfo(std::vector &dirs, const QString &dirId); SyncthingDev *addDevInfo(std::vector &devs, const QString &devId); diff --git a/syncthingconnector/syncthingconnection_requests.cpp b/syncthingconnector/syncthingconnection_requests.cpp index dcffefc..f914871 100644 --- a/syncthingconnector/syncthingconnection_requests.cpp +++ b/syncthingconnector/syncthingconnection_requests.cpp @@ -341,7 +341,7 @@ bool SyncthingConnection::resumeAllDevs() * \remarks This might result in errors caused by Syncthing not handling E notation correctly when using Qt < 5.9, * see https://github.com/syncthing/syncthing/issues/4001. */ -bool SyncthingConnection::pauseResumeDevice(const QStringList &devIds, bool paused) +bool SyncthingConnection::pauseResumeDevice(const QStringList &devIds, bool paused, bool dueToMetered) { if (devIds.isEmpty()) { return false; @@ -364,7 +364,7 @@ bool SyncthingConnection::pauseResumeDevice(const QStringList &devIds, bool paus QObject::connect(reply, &QNetworkReply::finished, this, &SyncthingConnection::readDevPauseResume); // avoid considering manually paused or resumed devices when the network connection is no longer metered - if (!m_devsPausedDueToMeteredConnection.isEmpty()) { + if (!dueToMetered && !m_devsPausedDueToMeteredConnection.isEmpty()) { for (const auto &devId : devIds) { m_devsPausedDueToMeteredConnection.removeAll(devId); }