From c071ef4cfbd783e509d31df71ca3c0f01aab3282 Mon Sep 17 00:00:00 2001 From: Christian Kandeler <christian.kandeler@nokia.com> Date: Thu, 13 Oct 2011 09:52:51 +0200 Subject: [PATCH] RemoteLinux: More helpful message for SFTP upload failures. Also introduce convenience funtion to DeployableFile. Change-Id: I271f47a4ecb0b410e1ef36727c735d0cd2f4ff69 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com> --- src/plugins/remotelinux/deployablefile.h | 5 +++++ .../remotelinux/genericdirectuploadservice.cpp | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/remotelinux/deployablefile.h b/src/plugins/remotelinux/deployablefile.h index b3b202254ba..fcd2a835b2f 100644 --- a/src/plugins/remotelinux/deployablefile.h +++ b/src/plugins/remotelinux/deployablefile.h @@ -35,6 +35,7 @@ #include "remotelinux_export.h" +#include <QtCore/QFileInfo> #include <QtCore/QHash> #include <QtCore/QString> @@ -54,6 +55,10 @@ public: && remoteDir == other.remoteDir; } + QString remoteFilePath() const { + return remoteDir + QLatin1Char('/') + QFileInfo(localFilePath).fileName(); + } + QString localFilePath; QString remoteDir; }; diff --git a/src/plugins/remotelinux/genericdirectuploadservice.cpp b/src/plugins/remotelinux/genericdirectuploadservice.cpp index 16f5e7dcd20..85925e3d893 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.cpp +++ b/src/plugins/remotelinux/genericdirectuploadservice.cpp @@ -159,8 +159,13 @@ void GenericDirectUploadService::handleUploadFinished(Utils::SftpJobId jobId, co const DeployableFile df = d->filesToUpload.takeFirst(); if (!errorMsg.isEmpty()) { - emit errorMessage(tr("Upload of file '%1' failed: %2") - .arg(QDir::toNativeSeparators(df.localFilePath), errorMsg)); + QString errorString = tr("Upload of file '%1' failed. The server said: '%2'.") + .arg(QDir::toNativeSeparators(df.localFilePath), errorMsg); + if (errorMsg == QLatin1String("Failure") && df.remoteDir.contains(QLatin1String("/bin"))) { + errorString += QLatin1Char(' ') + tr("If '%1' is currently running " + "on the remote host, you might need to stop it first.").arg(df.remoteFilePath()); + } + emit errorMessage(errorString); setFinished(); handleDeploymentDone(); } else { @@ -168,9 +173,7 @@ void GenericDirectUploadService::handleUploadFinished(Utils::SftpJobId jobId, co // Terrible hack for Windows. if (df.remoteDir.contains(QLatin1String("bin"))) { - const QString remoteFilePath = df.remoteDir + QLatin1Char('/') - + QFileInfo(df.localFilePath).fileName(); - const QString command = QLatin1String("chmod a+x ") + remoteFilePath; + const QString command = QLatin1String("chmod a+x ") + df.remoteFilePath(); connection()->createRemoteProcess(command.toUtf8())->start(); } -- GitLab