]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Selective Sync: Fix request loop and show error in view (#5154)
authorMarkus Goetz <markus@woboq.com>
Tue, 6 Sep 2016 09:11:03 +0000 (11:11 +0200)
committerChristian Kamm <mail@ckamm.de>
Mon, 12 Sep 2016 12:09:12 +0000 (14:09 +0200)
I got into a situation where the model would endlessly request the directory
contents from the server because we did not notice yet that the server
is actually in maintenance mode while we were expanding the tree view when
changing the tab to the account or when just expanding it by clicking.
(cherry picked from commit 524220d0907713408298a36df18bd04635ce5563)

src/gui/folderstatusmodel.cpp
src/gui/folderstatusmodel.h

index 746708b1517fcbeda4375dce56124a7add389167..6fab1095e648a10b1e6277564bdfb6433e7612b5 100644 (file)
@@ -164,7 +164,8 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
         switch(role) {
             case Qt::DisplayRole:
                 if (x->_hasError) {
-                    return tr("Error while loading the list of folders from the server.");
+                    return QVariant(tr("Error while loading the list of folders from the server.")
+                                               + QString("\n") + x->_lastErrorString);
                 } else {
                     return tr("Fetching folder list from server...");
                 }
@@ -498,6 +499,10 @@ bool FolderStatusModel::canFetchMore(const QModelIndex& parent) const
     auto info = infoForIndex(parent);
     if (!info || info->_fetched || info->_fetching)
         return false;
+    if (info->_hasError) {
+        // Keep showing the error to the user, it will be hidden when the account reconnects
+        return false;
+    }
     return true;
 }
 
@@ -548,6 +553,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
 
     if (parentInfo->hasLabel()) {
         beginRemoveRows(idx, 0 ,0);
+        parentInfo->_lastErrorString.clear();
         parentInfo->_hasError = false;
         parentInfo->_fetchingLabel = false;
         endRemoveRows();
@@ -675,6 +681,9 @@ void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply* r)
     }
     auto parentInfo = infoForIndex(idx);
     if (parentInfo) {
+        qDebug() << r->errorString();
+        parentInfo->_lastErrorString = r->errorString();
+
         if (r->error() == QNetworkReply::ContentNotFoundError) {
             parentInfo->_fetched = true;
         } else {
index f12de02270fb41fc5698930c98af3008b9c3f8b9..312e978aec32d65708a83d8aac1f68b492d69a0d 100644 (file)
@@ -63,6 +63,7 @@ public:
         bool _fetched; // If we did the LSCOL for this folder already
         bool _fetching; // Whether a LSCOL job is currently running
         bool _hasError; // If the last fetching job ended in an error
+        QString _lastErrorString;
         bool _fetchingLabel; // Whether a 'fetching in progress' label is shown.
 
         bool _isUndecided; // undecided folders are the big folders that the user has not accepted yet