mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
AddFolder: Improve remote path selection error handling #3573
This commit is contained in:
parent
07ca0be3c5
commit
035e57cf37
@ -240,7 +240,7 @@ void FolderWizardRemotePath::slotCreateRemoteFolder(const QString &folder)
|
||||
/* check the owncloud configuration file and query the ownCloud */
|
||||
connect(job, SIGNAL(finished(QNetworkReply::NetworkError)),
|
||||
SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
|
||||
connect(job, SIGNAL(networkError(QNetworkReply*)), SLOT(slotHandleNetworkError(QNetworkReply*)));
|
||||
connect(job, SIGNAL(networkError(QNetworkReply*)), SLOT(slotHandleMkdirNetworkError(QNetworkReply*)));
|
||||
job->start();
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ void FolderWizardRemotePath::slotCreateRemoteFolderFinished(QNetworkReply::Netwo
|
||||
}
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotHandleNetworkError(QNetworkReply *reply)
|
||||
void FolderWizardRemotePath::slotHandleMkdirNetworkError(QNetworkReply *reply)
|
||||
{
|
||||
qDebug() << "** webdav mkdir request failed:" << reply->error();
|
||||
if( reply && !_account->credentials()->stillValid(reply) ) {
|
||||
@ -266,6 +266,12 @@ void FolderWizardRemotePath::slotHandleNetworkError(QNetworkReply *reply)
|
||||
}
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotHandleLsColNetworkError(QNetworkReply *reply)
|
||||
{
|
||||
showWarn(tr("Failed to list a folder. Error: %1")
|
||||
.arg(errorMessage(reply->errorString(), reply->readAll())));
|
||||
}
|
||||
|
||||
static QTreeWidgetItem* findFirstChild(QTreeWidgetItem *parent, const QString& text)
|
||||
{
|
||||
for (int i = 0; i < parent->childCount(); ++i) {
|
||||
@ -356,11 +362,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
|
||||
|
||||
void FolderWizardRemotePath::slotRefreshFolders()
|
||||
{
|
||||
LsColJob *job = new LsColJob(_account, "/", this);
|
||||
job->setProperties(QList<QByteArray>() << "resourcetype");
|
||||
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
|
||||
SLOT(slotUpdateDirectories(QStringList)));
|
||||
job->start();
|
||||
runLsColJob("/");
|
||||
_ui.folderTreeWidget->clear();
|
||||
_ui.folderEntry->clear();
|
||||
}
|
||||
@ -368,11 +370,7 @@ void FolderWizardRemotePath::slotRefreshFolders()
|
||||
void FolderWizardRemotePath::slotItemExpanded(QTreeWidgetItem *item)
|
||||
{
|
||||
QString dir = item->data(0, Qt::UserRole).toString();
|
||||
LsColJob *job = new LsColJob(_account, dir, this);
|
||||
job->setProperties(QList<QByteArray>() << "resourcetype");
|
||||
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
|
||||
SLOT(slotUpdateDirectories(QStringList)));
|
||||
job->start();
|
||||
runLsColJob(dir);
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotCurrentItemChanged(QTreeWidgetItem *item)
|
||||
@ -405,11 +403,11 @@ void FolderWizardRemotePath::slotLsColFolderEntry()
|
||||
if (path.startsWith(QLatin1Char('/')))
|
||||
path = path.mid(1);
|
||||
|
||||
LsColJob *job = new LsColJob(_account, path, this);
|
||||
job->setProperties(QList<QByteArray>() << "resourcetype");
|
||||
LsColJob *job = runLsColJob(path);
|
||||
// no error handling, no updating, we do this manually
|
||||
disconnect(job, 0, this, 0);
|
||||
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
|
||||
SLOT(slotTypedPathFound(QStringList)));
|
||||
job->start();
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotTypedPathFound(const QStringList& subpaths)
|
||||
@ -418,6 +416,19 @@ void FolderWizardRemotePath::slotTypedPathFound(const QStringList& subpaths)
|
||||
selectByPath(_ui.folderEntry->text());
|
||||
}
|
||||
|
||||
LsColJob* FolderWizardRemotePath::runLsColJob(const QString& path)
|
||||
{
|
||||
LsColJob *job = new LsColJob(_account, path, this);
|
||||
job->setProperties(QList<QByteArray>() << "resourcetype");
|
||||
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
|
||||
SLOT(slotUpdateDirectories(QStringList)));
|
||||
connect(job, SIGNAL(finishedWithError(QNetworkReply*)),
|
||||
SLOT(slotHandleLsColNetworkError(QNetworkReply*)));
|
||||
job->start();
|
||||
|
||||
return job;
|
||||
}
|
||||
|
||||
FolderWizardRemotePath::~FolderWizardRemotePath()
|
||||
{
|
||||
}
|
||||
|
||||
@ -89,7 +89,8 @@ protected slots:
|
||||
void slotAddRemoteFolder();
|
||||
void slotCreateRemoteFolder(const QString&);
|
||||
void slotCreateRemoteFolderFinished(QNetworkReply::NetworkError error);
|
||||
void slotHandleNetworkError(QNetworkReply*);
|
||||
void slotHandleMkdirNetworkError(QNetworkReply*);
|
||||
void slotHandleLsColNetworkError(QNetworkReply*);
|
||||
void slotUpdateDirectories(const QStringList&);
|
||||
void slotRefreshFolders();
|
||||
void slotItemExpanded(QTreeWidgetItem*);
|
||||
@ -98,6 +99,7 @@ protected slots:
|
||||
void slotLsColFolderEntry();
|
||||
void slotTypedPathFound(const QStringList& subpaths);
|
||||
private:
|
||||
LsColJob* runLsColJob(const QString& path);
|
||||
void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QString path);
|
||||
bool selectByPath(QString path);
|
||||
Ui_FolderWizardTargetPage _ui;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user