Fix resuming devs when network not metered anymore after 57d47de7

This commit is contained in:
Martchus 2024-02-18 00:53:28 +01:00
parent 960f43f82a
commit 572e82cec0
3 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -365,7 +365,7 @@ private:
Reply prepareReply(QNetworkReply *&expectedReply, bool readData = true, bool handleAborting = true);
Reply prepareReply(QList<QNetworkReply *> &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<SyncthingDir> &dirs, const QString &dirId);
SyncthingDev *addDevInfo(std::vector<SyncthingDev> &devs, const QString &devId);

View File

@ -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);
}