[Pkg-owncloud-commits] [owncloud-client] 10/175: AccountState: Treat *any* 503 as a temporary error. #3113

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:20 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 73e2254a808c85afa54f2d54497b120b36e122fc
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Fri Apr 24 11:32:47 2015 +0200

    AccountState: Treat *any* 503 as a temporary error. #3113
---
 src/gui/accountsettings.cpp         |  6 +++---
 src/gui/accountstate.cpp            | 12 ++++++------
 src/gui/accountstate.h              |  8 ++++----
 src/gui/application.cpp             |  2 +-
 src/gui/owncloudgui.cpp             |  2 +-
 src/libsync/connectionvalidator.cpp | 13 ++++---------
 src/libsync/connectionvalidator.h   |  2 +-
 7 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index f46cf80..919bae5 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -234,7 +234,7 @@ void AccountSettings::slotAddFolder( Folder *folder )
     if( ! folder || folder->alias().isEmpty() ) return;
 
     QStandardItem *item = new QStandardItem();
-    folderToModelItem( item, folder, _accountState && _accountState->isConnectedOrMaintenance());
+    folderToModelItem( item, folder, _accountState && _accountState->isConnectedOrTemporarilyUnavailable());
     _model->appendRow( item );
     // in order to update the enabled state of the "Sync now" button
     connect(folder, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection);
@@ -537,7 +537,7 @@ void AccountSettings::slotUpdateFolderState( Folder *folder )
     }
 
     if( item ) {
-        folderToModelItem( item, folder, _accountState->isConnectedOrMaintenance() );
+        folderToModelItem( item, folder, _accountState->isConnectedOrTemporarilyUnavailable() );
     } else {
         // the dialog is not visible.
     }
@@ -794,7 +794,7 @@ void AccountSettings::slotAccountStateChanged(int state)
         foreach (Folder *folder, folderMan->map().values()) {
             slotUpdateFolderState(folder);
         }
-        if (state == AccountState::Connected || state == AccountState::ServerMaintenance) {
+        if (state == AccountState::Connected || state == AccountState::ServiceUnavailable) {
             QString user;
             if (AbstractCredentials *cred = account->credentials()) {
                user = cred->user();
diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp
index 43f8762..a2c9cf6 100644
--- a/src/gui/accountstate.cpp
+++ b/src/gui/accountstate.cpp
@@ -129,8 +129,8 @@ QString AccountState::stateString(State state)
         return QLatin1String("Disconnected");
     case Connected:
         return QLatin1String("Connected");
-    case ServerMaintenance:
-        return QLatin1String("ServerMaintenance");
+    case ServiceUnavailable:
+        return QLatin1String("ServiceUnavailable");
     case NetworkError:
         return QLatin1String("NetworkError");
     case ConfigurationError:
@@ -158,9 +158,9 @@ bool AccountState::isConnected() const
     return _state == Connected;
 }
 
-bool AccountState::isConnectedOrMaintenance() const
+bool AccountState::isConnectedOrTemporarilyUnavailable() const
 {
-    return isConnected() || _state == ServerMaintenance;
+    return isConnected() || _state == ServiceUnavailable;
 }
 
 QuotaInfo *AccountState::quotaInfo()
@@ -234,8 +234,8 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta
     case ConnectionValidator::UserCanceledCredentials:
         setState(SignedOut);
         break;
-    case ConnectionValidator::ServerMaintenance:
-        setState(ServerMaintenance);
+    case ConnectionValidator::ServiceUnavailable:
+        setState(ServiceUnavailable);
         break;
     case ConnectionValidator::Timeout:
         setState(NetworkError);
diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h
index 8da575b..c21b25e 100644
--- a/src/gui/accountstate.h
+++ b/src/gui/accountstate.h
@@ -67,9 +67,9 @@ public:
         /// The account is successfully talking to the server.
         Connected,
 
-        /// The account is talking to the server, but the server is in
-        /// maintenance mode.
-        ServerMaintenance,
+        /// There's a temporary problem with talking to the server,
+        /// don't bother the user too much and try again.
+        ServiceUnavailable,
 
         /// Could not communicate with the server for some reason.
         /// We assume this may resolve itself over time and will try
@@ -100,7 +100,7 @@ public:
     void setSignedOut(bool signedOut);
 
     bool isConnected() const;
-    bool isConnectedOrMaintenance() const;
+    bool isConnectedOrTemporarilyUnavailable() const;
 
     QuotaInfo *quotaInfo();
 
diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index 946384e..2ed510c 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -270,7 +270,7 @@ void Application::slotAccountStateChanged(int state)
         folderMan->setSyncEnabled(true);
         folderMan->slotScheduleAllFolders();
         break;
-    case AccountState::ServerMaintenance:
+    case AccountState::ServiceUnavailable:
     case AccountState::SignedOut:
     case AccountState::ConfigurationError:
     case AccountState::NetworkError:
diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp
index 48ec2b5..6894483 100644
--- a/src/gui/owncloudgui.cpp
+++ b/src/gui/owncloudgui.cpp
@@ -221,7 +221,7 @@ void ownCloudGui::slotComputeOverallSyncStatus()
             _tray->setToolTip(tr("Please sign in"));
             return;
         }
-        if (!a->isConnectedOrMaintenance()) {
+        if (!a->isConnectedOrTemporarilyUnavailable()) {
             _tray->setIcon(Theme::instance()->folderOfflineIcon(true));
             _tray->setToolTip(tr("Disconnected from server"));
             return;
diff --git a/src/libsync/connectionvalidator.cpp b/src/libsync/connectionvalidator.cpp
index b79b11b..89e61ed 100644
--- a/src/libsync/connectionvalidator.cpp
+++ b/src/libsync/connectionvalidator.cpp
@@ -48,8 +48,8 @@ QString ConnectionValidator::statusString( Status stat )
         return QLatin1String("Status not found");
     case UserCanceledCredentials:
         return QLatin1String("User canceled credentials");
-    case ServerMaintenance:
-        return QLatin1String("Server in maintenance mode");
+    case ServiceUnavailable:
+        return QLatin1String("Service unavailable");
     case Timeout:
         return QLatin1String("Timeout");
     }
@@ -192,13 +192,8 @@ void ConnectionValidator::slotAuthFailed(QNetworkReply *reply)
         const int httpStatus =
                 reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
         if ( httpStatus == 503 ) {
-            // Is this a maintenance mode reply from the server
-            // or a regular 503 from somewhere else?
-            QByteArray body = reply->readAll();
-            if ( body.contains("Sabre\\DAV\\Exception\\ServiceUnavailable") ) {
-                _errors.clear();
-                stat = ServerMaintenance;
-            }
+            _errors.clear();
+            stat = ServiceUnavailable;
         }
     }
 
diff --git a/src/libsync/connectionvalidator.h b/src/libsync/connectionvalidator.h
index 92ffae5..4beb8df 100644
--- a/src/libsync/connectionvalidator.h
+++ b/src/libsync/connectionvalidator.h
@@ -77,7 +77,7 @@ public:
         CredentialsWrong,
         StatusNotFound,
         UserCanceledCredentials,
-        ServerMaintenance,
+        ServiceUnavailable,
         // actually also used for other errors on the authed request
         Timeout
     };

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