[Pkg-owncloud-commits] [owncloud-client] 355/484: AccountState: Avoid ConnectionCheck if ETag job was just done.

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:38:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 3d7fc711ca0900b0b763b8d45012048b344f8e72
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Mon Oct 19 11:50:26 2015 +0200

    AccountState: Avoid ConnectionCheck if ETag job was just done.
    
    This patch lets a successful etag job check mark a timestamp.
    If next time a connection check is requested, it is checked if
    the last ETag happened within the last 30 seconds and if so the
    connection check can be checked.
    
    This way we avoid half of the PROPFINDs if all goes well.
---
 src/gui/accountstate.cpp | 15 +++++++++++++++
 src/gui/accountstate.h   |  9 +++++++++
 src/gui/folder.cpp       |  4 ++++
 3 files changed, 28 insertions(+)

diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp
index 1770c38..12c565d 100644
--- a/src/gui/accountstate.cpp
+++ b/src/gui/accountstate.cpp
@@ -39,6 +39,7 @@ AccountState::AccountState(AccountPtr account)
             SLOT(slotCredentialsFetched(AbstractCredentials*)));
     connect(account.data(), SIGNAL(credentialsAsked(AbstractCredentials*)),
             SLOT(slotCredentialsAsked(AbstractCredentials*)));
+    _timeSinceLastETagCheck.invalidate();
 }
 
 AccountState::~AccountState()
@@ -135,6 +136,11 @@ bool AccountState::isConnectedOrTemporarilyUnavailable() const
     return isConnected() || _state == ServiceUnavailable;
 }
 
+void AccountState::tagLastSuccessfullETagRequest()
+{
+    _timeSinceLastETagCheck.restart();
+}
+
 void AccountState::checkConnectivity(CredentialFetchMode credentialsFetchMode)
 {
     if (isSignedOut() || _waitingForNewCredentials) {
@@ -145,6 +151,15 @@ void AccountState::checkConnectivity(CredentialFetchMode credentialsFetchMode)
         qDebug() << "ConnectionValidator already running, ignoring" << account()->displayName();
         return;
     }
+
+    // IF the account is connected the connection check can be skipped
+    // if the last successful etag check job is not so long ago.
+    if (isConnected() && _timeSinceLastETagCheck.isValid()
+            && _timeSinceLastETagCheck.elapsed() < 30*1000) {
+        qDebug() << "The last ETag check succeeded within the last 30 secs. No connection check needed!";
+        return;
+    }
+
     _credentialsFetchMode = credentialsFetchMode;
     ConnectionValidator * conValidator = new ConnectionValidator(account());
     _connectionValidator = conValidator;
diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h
index be14239..54e0653 100644
--- a/src/gui/accountstate.h
+++ b/src/gui/accountstate.h
@@ -95,6 +95,14 @@ public:
      */
     QString shortDisplayNameForSettings(int width = 0) const;
 
+    /** Mark the timestamp when the last successful ETag check happened for
+     *  this account.
+     *  The checkConnectivity() method uses the timestamp to save a call to
+     *  the server to validate the connection if the last successful etag job
+     *  is not so lang away.
+     */
+    void tagLastSuccessfullETagRequest();
+
 private:
     void setState(State state);
 
@@ -114,6 +122,7 @@ private:
     QStringList _connectionErrors;
     bool _waitingForNewCredentials;
     CredentialFetchMode _credentialsFetchMode;
+    QElapsedTimer _timeSinceLastETagCheck;
     QPointer<ConnectionValidator> _connectionValidator;
 };
 
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index 72ab2ea..de05909 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -365,6 +365,10 @@ void Folder::etagRetreived(const QString& etag)
         _lastEtag = etag;
         emit scheduleToSync(this);
     }
+
+    if( _accountState ) {
+        _accountState->tagLastSuccessfullETagRequest();
+    }
 }
 
 void Folder::etagRetreivedFromSyncEngine(const QString& etag)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list