diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2020-12-03 18:27:43 +0300 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-15 13:01:08 +0300 |
commit | 9d9eadba8e33a1c67861e8bb21ce604f2fc90b6d (patch) | |
tree | f2c04525fd3ff036ef04261e0f6ce5a2450ec98f /src/gui/accountstate.cpp | |
parent | 6818b8e30323e4b8efab40796ca352342a7405aa (diff) |
Use time the request was send,..
not when it was processed by the client, to determine the quality of the connection.
Diffstat (limited to 'src/gui/accountstate.cpp')
-rw-r--r-- | src/gui/accountstate.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index 4aace2e9c..90c05fefe 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -53,7 +53,6 @@ AccountState::AccountState(AccountPtr account) this, &AccountState::slotCredentialsFetched); connect(account.data(), &Account::credentialsAsked, this, &AccountState::slotCredentialsAsked); - _timeSinceLastETagCheck.invalidate(); connect(this, &AccountState::isConnectedChanged, [=]{ // Get the Apps available on the server if we're now connected. @@ -181,9 +180,9 @@ bool AccountState::isConnected() const return _state == Connected; } -void AccountState::tagLastSuccessfullETagRequest() +void AccountState::tagLastSuccessfullETagRequest(const QDateTime &tp) { - _timeSinceLastETagCheck.start(); + _timeOfLastETagCheck = tp; } QByteArray AccountState::notificationsEtagResponseHeader() const @@ -227,12 +226,11 @@ void AccountState::checkConnectivity() // IF the account is connected the connection check can be skipped // if the last successful etag check job is not so long ago. - ConfigFile cfg; - std::chrono::milliseconds polltime = cfg.remotePollInterval(); - - if (isConnected() && _timeSinceLastETagCheck.isValid() - && !_timeSinceLastETagCheck.hasExpired(polltime.count())) { - qCDebug(lcAccountState) << account()->displayName() << "The last ETag check succeeded within the last " << polltime.count() / 1000 << " secs. No connection check needed!"; + const auto polltime = std::chrono::duration_cast<std::chrono::seconds>(ConfigFile().remotePollInterval()); + const auto elapsed = _timeOfLastETagCheck.secsTo(QDateTime::currentDateTimeUtc()); + if (isConnected() && _timeOfLastETagCheck.isValid() + && elapsed <= polltime.count()) { + qCDebug(lcAccountState) << account()->displayName() << "The last ETag check succeeded within the last " << polltime.count() << "s (" << elapsed << "s). No connection check needed!"; return; } |