mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Selective Sync: Fix request loop and show error in view (#5154)
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 524220d090
)
This commit is contained in:
parent
cb19ebc9e3
commit
3cdcd8dea0
2 changed files with 11 additions and 1 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue