[Pkg-owncloud-commits] [owncloud-client] 120/498: FolderStatusModel: handle network error in the LSCol
Sandro Knauß
hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:42 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 e1f94cea4f727e358e2c0bcba9b8a6c2315c7635
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue Jun 2 20:15:16 2015 +0200
FolderStatusModel: handle network error in the LSCol
---
src/gui/folderstatusmodel.cpp | 23 +++++++++++++++++++++--
src/gui/folderstatusmodel.h | 2 ++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index 3cb2ac3..69aecf5 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -352,14 +352,18 @@ bool FolderStatusModel::canFetchMore(const QModelIndex& parent) const
void FolderStatusModel::fetchMore(const QModelIndex& parent)
{
auto info = infoForIndex(parent);
+
if (!info || info->_fetched || info->_fetching)
return;
info->_fetching = true;
LsColJob *job = new LsColJob(_account, info->_folder->remotePath() + "/" + info->_path, this);
job->setProperties(QList<QByteArray>() << "resourcetype" << "quota-used-bytes");
+ job->setTimeout(5 * 1000);
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
SLOT(slotUpdateDirectories(QStringList)));
+ connect(job, SIGNAL(finishedWithError(QNetworkReply*)),
+ this, SLOT(slotLscolFinishedWithError(QNetworkReply*)));
job->start();
job->setProperty(propertyParentIndexC , QVariant::fromValue<QPersistentModelIndex>(parent));
}
@@ -421,15 +425,30 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
endInsertRows();
}
-/*void SelectiveSyncTreeView::slotLscolFinishedWithError(QNetworkReply *r)
+void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply* r)
{
+/*
if (r->error() == QNetworkReply::ContentNotFoundError) {
_loading->setText(tr("No subfolders currently on the server."));
} else {
_loading->setText(tr("An error occured while loading the list of sub folders."));
}
_loading->resize(_loading->sizeHint()); // because it's not in a layout
-}*/
+*/
+ auto job = qobject_cast<LsColJob *>(sender());
+ Q_ASSERT(job);
+ QModelIndex idx = qvariant_cast<QPersistentModelIndex>(job->property(propertyParentIndexC));
+ if (!idx.isValid()) {
+ return;
+ }
+ auto parentInfo = infoForIndex(idx);
+ if (parentInfo) {
+ parentInfo->_fetching = false;
+ if (r->error() == QNetworkReply::ContentNotFoundError) {
+ parentInfo->_fetched = true;
+ }
+ }
+}
QStringList FolderStatusModel::createBlackList(FolderStatusModel::SubFolderInfo *root,
const QStringList &oldBlackList) const
diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h
index 2d8f713..8989fc9 100644
--- a/src/gui/folderstatusmodel.h
+++ b/src/gui/folderstatusmodel.h
@@ -19,6 +19,7 @@
#include <QStandardItemModel>
#include <accountfwd.h>
+class QNetworkReply;
namespace OCC {
class Folder;
@@ -85,6 +86,7 @@ private slots:
void slotUpdateDirectories(const QStringList &);
void slotHideProgress();
void slotFolderSyncStateChange();
+ void slotLscolFinishedWithError(QNetworkReply *r);
private:
QStringList createBlackList(OCC::FolderStatusModel::SubFolderInfo* root,
--
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