diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 57bb4e385ed7a..3d7b69eb5c28e 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -669,16 +669,27 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings) } acc->setCredentials(CredentialsFactory::create(authType)); - acc->setUploadLimitSetting( - settings.value( - networkUploadLimitSettingC, - QVariant::fromValue(Account::AccountNetworkTransferLimitSetting::NoLimit) - ).value()); - acc->setDownloadLimitSetting( - settings.value( - networkDownloadLimitSettingC, - QVariant::fromValue(Account::AccountNetworkTransferLimitSetting::NoLimit) - ).value()); + auto uploadLimitSetting = settings.value( + networkUploadLimitSettingC, + QVariant::fromValue(Account::AccountNetworkTransferLimitSetting::NoLimit) + ).value(); + if (uploadLimitSetting == Account::AccountNetworkTransferLimitSetting::AutoLimit) { + qCInfo(lcAccountManager) << "Upload limit setting was set to deprecated auto limit, falling back to unlimited"; + uploadLimitSetting = Account::AccountNetworkTransferLimitSetting::NoLimit; + settings.setValue(networkUploadLimitSettingC, QVariant::fromValue(uploadLimitSetting)); + } + acc->setUploadLimitSetting(uploadLimitSetting); + + auto downloadLimitSetting = settings.value( + networkDownloadLimitSettingC, + QVariant::fromValue(Account::AccountNetworkTransferLimitSetting::NoLimit) + ).value(); + if (downloadLimitSetting == Account::AccountNetworkTransferLimitSetting::AutoLimit) { + qCInfo(lcAccountManager) << "Download limit setting was set to deprecated auto limit, falling back to unlimited"; + downloadLimitSetting = Account::AccountNetworkTransferLimitSetting::NoLimit; + settings.setValue(networkDownloadLimitSettingC, QVariant::fromValue(downloadLimitSetting)); + } + acc->setDownloadLimitSetting(downloadLimitSetting); acc->setUploadLimit(settings.value(networkUploadLimitC).toInt()); acc->setDownloadLimit(settings.value(networkDownloadLimitC).toInt()); diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 5eeae1f1cc94f..2a3556b6588fa 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -1233,7 +1233,7 @@ void Folder::setDirtyNetworkLimits() ConfigFile cfg; - int downloadLimit = -75; // 75% + int downloadLimit = 0; const auto useDownLimit = static_cast>(account->downloadLimitSetting()); if (useDownLimit >= 1) { downloadLimit = account->downloadLimit() * 1000; @@ -1241,7 +1241,7 @@ void Folder::setDirtyNetworkLimits() downloadLimit = 0; } - int uploadLimit = -75; // 75% + int uploadLimit = 0; const auto useUpLimit = static_cast>(account->uploadLimitSetting()); if (useUpLimit >= 1) { uploadLimit = account->uploadLimit() * 1000; diff --git a/src/gui/networksettings.cpp b/src/gui/networksettings.cpp index eb73c7f4c3036..26f19ecde85b3 100644 --- a/src/gui/networksettings.cpp +++ b/src/gui/networksettings.cpp @@ -79,10 +79,8 @@ NetworkSettings::NetworkSettings(const AccountPtr &account, QWidget *parent) connect(_ui->uploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->noUploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); - connect(_ui->autoUploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->downloadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->noDownloadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); - connect(_ui->autoDownloadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->downloadSpinBox, static_cast(&QSpinBox::valueChanged), this, &NetworkSettings::saveBWLimitSettings); connect(_ui->uploadSpinBox, static_cast(&QSpinBox::valueChanged), this, &NetworkSettings::saveBWLimitSettings); } @@ -148,19 +146,15 @@ void NetworkSettings::loadBWLimitSettings() if (useDownloadLimit >= 1) { _ui->downloadLimitRadioButton->setChecked(true); - } else if (useDownloadLimit == 0) { - _ui->noDownloadLimitRadioButton->setChecked(true); } else { - _ui->autoDownloadLimitRadioButton->setChecked(true); + _ui->noDownloadLimitRadioButton->setChecked(true); } _ui->downloadSpinBox->setValue(downloadLimit); if (useUploadLimit >= 1) { _ui->uploadLimitRadioButton->setChecked(true); - } else if (useUploadLimit == 0) { - _ui->noUploadLimitRadioButton->setChecked(true); } else { - _ui->autoUploadLimitRadioButton->setChecked(true); + _ui->noUploadLimitRadioButton->setChecked(true); } _ui->uploadSpinBox->setValue(uploadLimit); } @@ -208,8 +202,6 @@ void NetworkSettings::saveBWLimitSettings() useDownloadLimit = 1; } else if (_ui->noDownloadLimitRadioButton->isChecked()) { useDownloadLimit = 0; - } else if (_ui->autoDownloadLimitRadioButton->isChecked()) { - useDownloadLimit = -1; } else if (_account) { useDownloadLimit = -2; } @@ -218,8 +210,6 @@ void NetworkSettings::saveBWLimitSettings() useUploadLimit = 1; } else if (_ui->noUploadLimitRadioButton->isChecked()) { useUploadLimit = 0; - } else if (_ui->autoUploadLimitRadioButton->isChecked()) { - useUploadLimit = -1; } else if (_account) { useUploadLimit = -2; } diff --git a/src/gui/networksettings.ui b/src/gui/networksettings.ui index 068cc6e8967af..350e78e25bb23 100644 --- a/src/gui/networksettings.ui +++ b/src/gui/networksettings.ui @@ -314,7 +314,7 @@ 6 - + Limit to @@ -331,17 +331,7 @@ - - - - Limit to 3/4 of estimated bandwidth - - - Limit automatically - - - - + @@ -371,7 +361,7 @@ - + Qt::Orientation::Vertical @@ -414,7 +404,7 @@ 6 - + @@ -447,23 +437,13 @@ - + Limit to - - - - Limit to 3/4 of estimated bandwidth - - - Limit automatically - - - @@ -474,7 +454,7 @@ - + Qt::Orientation::Vertical @@ -488,7 +468,6 @@ - autoUploadLimitRadioButton uploadLimitRadioButton noUploadLimitRadioButton verticalSpacer_3 diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 8ad4997646aca..9e88e48ba7cdf 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -1475,6 +1475,10 @@ void Account::setUploadLimitSetting(const AccountNetworkTransferLimitSetting set qCInfo(lcAccount) << "Upload limit setting was requested to be set to the legacy global limit, falling back to unlimited"; targetSetting = AccountNetworkTransferLimitSetting::NoLimit; } + if (setting == AccountNetworkTransferLimitSetting::AutoLimit) { + qCInfo(lcAccount) << "Upload limit setting was requested to be set to the deprecated auto limit, falling back to unlimited"; + targetSetting = AccountNetworkTransferLimitSetting::NoLimit; + } _uploadLimitSetting = targetSetting; emit uploadLimitSettingChanged(); @@ -1497,6 +1501,10 @@ void Account::setDownloadLimitSetting(const AccountNetworkTransferLimitSetting s qCInfo(lcAccount) << "Download limit setting was requested to be set to the legacy global limit, falling back to unlimited"; targetSetting = AccountNetworkTransferLimitSetting::NoLimit; } + if (setting == AccountNetworkTransferLimitSetting::AutoLimit) { + qCInfo(lcAccount) << "Download limit setting was requested to be set to the deprecated auto limit, falling back to unlimited"; + targetSetting = AccountNetworkTransferLimitSetting::NoLimit; + } _downloadLimitSetting = targetSetting; emit downloadLimitSettingChanged(); diff --git a/src/libsync/account.h b/src/libsync/account.h index d3daf13f28d92..12c16850efe42 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -104,7 +104,7 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject public: enum class AccountNetworkTransferLimitSetting { LegacyGlobalLimit = -2, // Until 3.17.0 a value of -2 was interpreted as "Use global network settings", it's now used to fall back to "No limit". See also GH#8743 - AutoLimit = -1, // Value under 0 is interpreted as auto in general + AutoLimit = -1, // Deprecated: auto limit removed, treated as "No limit" for migration NoLimit, ManualLimit, }; diff --git a/src/libsync/bandwidthmanager.cpp b/src/libsync/bandwidthmanager.cpp index e67148f998424..60d1f36998cd3 100644 --- a/src/libsync/bandwidthmanager.cpp +++ b/src/libsync/bandwidthmanager.cpp @@ -23,18 +23,10 @@ namespace OCC { Q_LOGGING_CATEGORY(lcBandwidthManager, "nextcloud.sync.bandwidthmanager", QtInfoMsg) -// Because of the many layers of buffering inside Qt (and probably the OS and the network) -// we cannot lower this value much more. If we do, the estimated bw will be very high -// because the buffers fill fast while the actual network algorithms are not relevant yet. -static qint64 relativeLimitMeasuringTimerIntervalMsec = 1000 * 2; -// See also WritingState in http://code.woboq.org/qt5/qtbase/src/network/access/qhttpprotocolhandler.cpp.html#_ZN20QHttpProtocolHandler11sendRequestEv - // FIXME At some point: // * Register device only after the QNR received its metaDataChanged() signal // * Incorporate Qt buffer fill state (it's a negative absolute delta). // * Incorporate SSL overhead (percentage) -// * For relative limiting, do less measuring and more delaying+giving quota -// * For relative limiting, smoothen measurements BandwidthManager::BandwidthManager(OwncloudPropagator *p) : QObject() @@ -53,25 +45,6 @@ BandwidthManager::BandwidthManager(OwncloudPropagator *p) _absoluteLimitTimer.setInterval(1000); _absoluteLimitTimer.start(); - // Relative uploads - QObject::connect(&_relativeUploadMeasuringTimer, &QTimer::timeout, - this, &BandwidthManager::relativeUploadMeasuringTimerExpired); - _relativeUploadMeasuringTimer.setInterval(relativeLimitMeasuringTimerIntervalMsec); - _relativeUploadMeasuringTimer.start(); - _relativeUploadMeasuringTimer.setSingleShot(true); // will be restarted from the delay timer - QObject::connect(&_relativeUploadDelayTimer, &QTimer::timeout, - this, &BandwidthManager::relativeUploadDelayTimerExpired); - _relativeUploadDelayTimer.setSingleShot(true); // will be restarted from the measuring timer - - // Relative downloads - QObject::connect(&_relativeDownloadMeasuringTimer, &QTimer::timeout, - this, &BandwidthManager::relativeDownloadMeasuringTimerExpired); - _relativeDownloadMeasuringTimer.setInterval(relativeLimitMeasuringTimerIntervalMsec); - _relativeDownloadMeasuringTimer.start(); - _relativeDownloadMeasuringTimer.setSingleShot(true); // will be restarted from the delay timer - QObject::connect(&_relativeDownloadDelayTimer, &QTimer::timeout, - this, &BandwidthManager::relativeDownloadDelayTimerExpired); - _relativeDownloadDelayTimer.setSingleShot(true); // will be restarted from the measuring timer } BandwidthManager::~BandwidthManager() = default; @@ -79,15 +52,11 @@ BandwidthManager::~BandwidthManager() = default; void BandwidthManager::registerUploadDevice(UploadDevice *p) { _absoluteUploadDeviceList.push_back(p); - _relativeUploadDeviceList.push_back(p); QObject::connect(p, &QObject::destroyed, this, &BandwidthManager::unregisterUploadDevice); if (usingAbsoluteUploadLimit()) { p->setBandwidthLimited(true); p->setChoked(false); - } else if (usingRelativeUploadLimit()) { - p->setBandwidthLimited(true); - p->setChoked(true); } else { p->setBandwidthLimited(false); p->setChoked(false); @@ -98,11 +67,6 @@ void BandwidthManager::unregisterUploadDevice(QObject *o) { auto p = reinterpret_cast(o); // note, we might already be in the ~QObject _absoluteUploadDeviceList.remove(p); - _relativeUploadDeviceList.remove(p); - if (p == _relativeLimitCurrentMeasuredDevice) { - _relativeLimitCurrentMeasuredDevice = nullptr; - _relativeUploadLimitProgressAtMeasuringRestart = 0; - } } void BandwidthManager::registerDownloadJob(GETFileJob *j) @@ -113,9 +77,6 @@ void BandwidthManager::registerDownloadJob(GETFileJob *j) if (usingAbsoluteDownloadLimit()) { j->setBandwidthLimited(true); j->setChoked(false); - } else if (usingRelativeDownloadLimit()) { - j->setBandwidthLimited(true); - j->setChoked(true); } else { j->setBandwidthLimited(false); j->setChoked(false); @@ -126,213 +87,8 @@ void BandwidthManager::unregisterDownloadJob(QObject *o) { auto *j = reinterpret_cast(o); // note, we might already be in the ~QObject _downloadJobList.remove(j); - if (_relativeLimitCurrentMeasuredJob == j) { - _relativeLimitCurrentMeasuredJob = nullptr; - _relativeDownloadLimitProgressAtMeasuringRestart = 0; - } } -void BandwidthManager::relativeUploadMeasuringTimerExpired() -{ - if (!usingRelativeUploadLimit() || _relativeUploadDeviceList.empty()) { - // Not in this limiting mode, just wait 1 sec to continue the cycle - _relativeUploadDelayTimer.setInterval(1000); - _relativeUploadDelayTimer.start(); - return; - } - - if (!_relativeLimitCurrentMeasuredDevice) { - qCDebug(lcBandwidthManager) << "No device set, just waiting 1 sec"; - _relativeUploadDelayTimer.setInterval(1000); - _relativeUploadDelayTimer.start(); - return; - } - - qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.size() << "Starting Delay"; - - const auto currentReadWithProgress = _relativeLimitCurrentMeasuredDevice->_readWithProgress; - const auto currentRead = _relativeLimitCurrentMeasuredDevice->_read; - const auto relativeLimitProgressMeasured = (currentReadWithProgress + currentRead) / 2; - const auto relativeLimitProgressDifference = relativeLimitProgressMeasured - _relativeUploadLimitProgressAtMeasuringRestart; - - qCDebug(lcBandwidthManager) << _relativeUploadLimitProgressAtMeasuringRestart - << relativeLimitProgressMeasured - << relativeLimitProgressDifference; - - const auto speedkBPerSec = (relativeLimitProgressDifference / relativeLimitMeasuringTimerIntervalMsec * 1000) / 1024; - - qCDebug(lcBandwidthManager) << relativeLimitProgressDifference / 1024 << "kB =>" << speedkBPerSec << "kB/sec on full speed (" - << currentReadWithProgress << currentRead - << qAbs(currentReadWithProgress - currentRead) - << ")"; - - const auto uploadLimitPercent = qMax( qMin(-_currentUploadLimit, qint64(90)), qint64(10) ); // Clamp value - const auto wholeTimeMsec = (100.0 / uploadLimitPercent) * relativeLimitMeasuringTimerIntervalMsec; - const auto waitTimeMsec = wholeTimeMsec - relativeLimitMeasuringTimerIntervalMsec; - const auto realWaitTimeMsec = waitTimeMsec + wholeTimeMsec; - - qCDebug(lcBandwidthManager) << waitTimeMsec << " - " << realWaitTimeMsec << " msec for " << uploadLimitPercent << "%"; - - // We want to wait twice as long since we want to give all - // devices the same quota we used now since we don't want - // any upload to timeout - _relativeUploadDelayTimer.setInterval(realWaitTimeMsec); - _relativeUploadDelayTimer.start(); - - const auto deviceCount = _relativeUploadDeviceList.size(); - const auto quotaPerDevice = relativeLimitProgressDifference * (uploadLimitPercent / 100.0) / deviceCount + 1.0; - - for (const auto uploadDevice : _relativeUploadDeviceList) { - uploadDevice->setBandwidthLimited(true); - uploadDevice->setChoked(false); - uploadDevice->giveBandwidthQuota(quotaPerDevice); - qCDebug(lcBandwidthManager) << "Gave" << quotaPerDevice / 1024.0 << "kB to" << uploadDevice; - } - - _relativeLimitCurrentMeasuredDevice = nullptr; -} - -void BandwidthManager::relativeUploadDelayTimerExpired() -{ - // Switch to measuring state - _relativeUploadMeasuringTimer.start(); // always start to continue the cycle - - if (!usingRelativeUploadLimit()) { - return; // oh, not actually needed - } - - if (_relativeUploadDeviceList.empty()) { - return; - } - - qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.size() << "Starting measuring"; - - // Take first device and then append it again (= we round robin all devices) - _relativeLimitCurrentMeasuredDevice = _relativeUploadDeviceList.front(); - _relativeUploadDeviceList.pop_front(); - _relativeUploadDeviceList.push_back(_relativeLimitCurrentMeasuredDevice); - - const auto currentReadWithProgress = _relativeLimitCurrentMeasuredDevice->_readWithProgress; - const auto currentRead = _relativeLimitCurrentMeasuredDevice->_read; - _relativeUploadLimitProgressAtMeasuringRestart = (currentReadWithProgress + currentRead) / 2; - - _relativeLimitCurrentMeasuredDevice->setBandwidthLimited(false); - _relativeLimitCurrentMeasuredDevice->setChoked(false); - - // choke all other UploadDevices - for (const auto uploadDevice : _relativeUploadDeviceList) { - if (uploadDevice == _relativeLimitCurrentMeasuredDevice) { - continue; - } - - uploadDevice->setBandwidthLimited(true); - uploadDevice->setChoked(true); - } - - // now we're in measuring state -} - -// for downloads: -void BandwidthManager::relativeDownloadMeasuringTimerExpired() -{ - if (!usingRelativeDownloadLimit() || _downloadJobList.empty()) { - // Not in this limiting mode, just wait 1 sec to continue the cycle - _relativeDownloadDelayTimer.setInterval(1000); - _relativeDownloadDelayTimer.start(); - return; - } - if (!_relativeLimitCurrentMeasuredJob) { - qCDebug(lcBandwidthManager) << "No job set, just waiting 1 sec"; - _relativeDownloadDelayTimer.setInterval(1000); - _relativeDownloadDelayTimer.start(); - return; - } - - qCDebug(lcBandwidthManager) << _downloadJobList.size() << "Starting Delay"; - - const auto relativeLimitProgressMeasured = _relativeLimitCurrentMeasuredJob->currentDownloadPosition(); - const auto relativeLimitProgressDifference = relativeLimitProgressMeasured - _relativeDownloadLimitProgressAtMeasuringRestart; - - qCDebug(lcBandwidthManager) << _relativeDownloadLimitProgressAtMeasuringRestart - << relativeLimitProgressMeasured << relativeLimitProgressDifference; - - const auto speedkBPerSec = (relativeLimitProgressDifference / relativeLimitMeasuringTimerIntervalMsec * 1000) / 1024; - - qCDebug(lcBandwidthManager) << relativeLimitProgressDifference / 1024 << "kB =>" << speedkBPerSec << "kB/sec on full speed (" - << _relativeLimitCurrentMeasuredJob->currentDownloadPosition(); - - const auto downloadLimitPercent = qMax( qMin(-_currentDownloadLimit, qint64(90)), qint64(10)); - const auto wholeTimeMsec = (100.0 / downloadLimitPercent) * relativeLimitMeasuringTimerIntervalMsec; - const auto waitTimeMsec = wholeTimeMsec - relativeLimitMeasuringTimerIntervalMsec; - const auto realWaitTimeMsec = waitTimeMsec + wholeTimeMsec; - - qCDebug(lcBandwidthManager) << waitTimeMsec << " - " << realWaitTimeMsec << " msec for " << downloadLimitPercent << "%"; - - // We want to wait twice as long since we want to give all - // devices the same quota we used now since we don't want - // any download to timeout - _relativeDownloadDelayTimer.setInterval(realWaitTimeMsec); - _relativeDownloadDelayTimer.start(); - - const auto jobCount = _downloadJobList.size(); - auto quota = relativeLimitProgressDifference * (downloadLimitPercent / 100.0); - - if (quota > 20 * 1024) { - qCDebug(lcBandwidthManager) << "ADJUSTING QUOTA FROM " << quota << " TO " << quota - 20 * 1024; - quota -= 20 * 1024; - } - - const auto quotaPerJob = quota / jobCount + 1; - for (const auto getFileJob : _downloadJobList) { - getFileJob->setBandwidthLimited(true); - getFileJob->setChoked(false); - getFileJob->giveBandwidthQuota(quotaPerJob); - - qCDebug(lcBandwidthManager) << "Gave" << quotaPerJob / 1024.0 << "kB to" << getFileJob; - } - _relativeLimitCurrentMeasuredDevice = nullptr; -} - -void BandwidthManager::relativeDownloadDelayTimerExpired() -{ - // Switch to measuring state - _relativeDownloadMeasuringTimer.start(); // always start to continue the cycle - - if (!usingRelativeDownloadLimit()) { - return; // oh, not actually needed - } - - if (_downloadJobList.empty()) { - qCDebug(lcBandwidthManager) << _downloadJobList.size() << "No jobs?"; - return; - } - - qCDebug(lcBandwidthManager) << _downloadJobList.size() << "Starting measuring"; - - // Take first device and then append it again (= we round robin all devices) - _relativeLimitCurrentMeasuredJob = _downloadJobList.front(); - _downloadJobList.pop_front(); - _downloadJobList.push_back(_relativeLimitCurrentMeasuredJob); - - _relativeDownloadLimitProgressAtMeasuringRestart = _relativeLimitCurrentMeasuredJob->currentDownloadPosition(); - _relativeLimitCurrentMeasuredJob->setBandwidthLimited(false); - _relativeLimitCurrentMeasuredJob->setChoked(false); - - // choke all other download jobs - for (const auto getFileJob : _downloadJobList) { - if (getFileJob == _relativeLimitCurrentMeasuredJob) { - continue; - } - - getFileJob->setBandwidthLimited(true); - getFileJob->setChoked(true); - } - - // now we're in measuring state -} - -// end downloads - void BandwidthManager::switchingTimerExpired() { const auto newUploadLimit = _propagator->_uploadLimit; @@ -340,15 +96,12 @@ void BandwidthManager::switchingTimerExpired() qCInfo(lcBandwidthManager) << "Upload Bandwidth limit changed" << _currentUploadLimit << newUploadLimit; _currentUploadLimit = newUploadLimit; - for (const auto uploadDevice : _relativeUploadDeviceList) { + for (const auto uploadDevice : _absoluteUploadDeviceList) { Q_ASSERT(uploadDevice); if (usingAbsoluteUploadLimit()) { uploadDevice->setBandwidthLimited(true); uploadDevice->setChoked(false); - } else if (usingRelativeUploadLimit()) { - uploadDevice->setBandwidthLimited(true); - uploadDevice->setChoked(true); } else { uploadDevice->setBandwidthLimited(false); uploadDevice->setChoked(false); @@ -367,9 +120,6 @@ void BandwidthManager::switchingTimerExpired() if (usingAbsoluteDownloadLimit()) { getJob->setBandwidthLimited(true); getJob->setChoked(false); - } else if (usingRelativeDownloadLimit()) { - getJob->setBandwidthLimited(true); - getJob->setChoked(true); } else { getJob->setBandwidthLimited(false); getJob->setChoked(false); diff --git a/src/libsync/bandwidthmanager.h b/src/libsync/bandwidthmanager.h index 3c7c1c88c6896..08c6ce5517c64 100644 --- a/src/libsync/bandwidthmanager.h +++ b/src/libsync/bandwidthmanager.h @@ -9,7 +9,6 @@ #include #include -#include #include namespace OCC { @@ -30,9 +29,7 @@ class BandwidthManager : public QObject ~BandwidthManager() override; bool usingAbsoluteUploadLimit() { return _currentUploadLimit > 0; } - bool usingRelativeUploadLimit() { return _currentUploadLimit < 0; } bool usingAbsoluteDownloadLimit() { return _currentDownloadLimit > 0; } - bool usingRelativeDownloadLimit() { return _currentDownloadLimit < 0; } public slots: @@ -45,14 +42,7 @@ public slots: void absoluteLimitTimerExpired(); void switchingTimerExpired(); - void relativeUploadMeasuringTimerExpired(); - void relativeUploadDelayTimerExpired(); - - void relativeDownloadMeasuringTimerExpired(); - void relativeDownloadDelayTimerExpired(); - private: - // for switching between absolute and relative bw limiting QTimer _switchingTimer; // FIXME this timer and this variable should be replaced @@ -62,34 +52,10 @@ public slots: // for absolute up/down bw limiting QTimer _absoluteLimitTimer; - // FIXME merge these two lists std::list _absoluteUploadDeviceList; - std::list _relativeUploadDeviceList; - - QTimer _relativeUploadMeasuringTimer; - - // for relative bw limiting, we need to wait this amount before measuring again - QTimer _relativeUploadDelayTimer; - - // the device measured - UploadDevice *_relativeLimitCurrentMeasuredDevice = nullptr; - - // for measuring how much progress we made at start - qint64 _relativeUploadLimitProgressAtMeasuringRestart = 0; qint64 _currentUploadLimit = 0; std::list _downloadJobList; - QTimer _relativeDownloadMeasuringTimer; - - // for relative bw limiting, we need to wait this amount before measuring again - QTimer _relativeDownloadDelayTimer; - - // the device measured - GETFileJob *_relativeLimitCurrentMeasuredJob = nullptr; - - // for measuring how much progress we made at start - qint64 _relativeDownloadLimitProgressAtMeasuringRestart = 0LL; - qint64 _currentDownloadLimit = 0; }; diff --git a/test/testaccount.cpp b/test/testaccount.cpp index e76b15877588d..e216250cc5e2b 100644 --- a/test/testaccount.cpp +++ b/test/testaccount.cpp @@ -89,9 +89,9 @@ private slots: setLimitSettings(LimitSetting::ManualLimit); verifyLimitSettings(LimitSetting::ManualLimit); - // changing it to AutoLimit should succeed + // changing it to AutoLimit should fall back to NoLimit setLimitSettings(LimitSetting::AutoLimit); - verifyLimitSettings(LimitSetting::AutoLimit); + verifyLimitSettings(LimitSetting::NoLimit); // changing it to LegacyGlobalLimit (-2) should fall back to NoLimit setLimitSettings(LimitSetting::LegacyGlobalLimit);