RemoteLinux: Fix upload for target file paths with spaces.

In addition to causing an unhelpful error message, we would also create
directories at unwanted places. For instance, deploying to a directory
called "/tmp/test dir" would result in this:
    mkdir -p /tmp/test dir
Which created two unwanted directories, one of them at a completely
unrelated place.

Task-number: QTCREATORBUG-14518
Change-Id: Ie1c287ca73d0815b9bed335141adb901e361e3e6
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Karsten Sperling Opdal
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
Christian Kandeler
2015-05-28 17:48:49 +02:00
parent 29d81424a2
commit 0879785839

View File

@@ -31,6 +31,7 @@
#include <projectexplorer/deployablefile.h> #include <projectexplorer/deployablefile.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <ssh/sftpchannel.h> #include <ssh/sftpchannel.h>
#include <ssh/sshconnection.h> #include <ssh/sshconnection.h>
#include <ssh/sshremoteprocess.h> #include <ssh/sshremoteprocess.h>
@@ -184,7 +185,8 @@ void GenericDirectUploadService::handleUploadFinished(SftpJobId jobId, const QSt
// This is done for Windows. // This is done for Windows.
if (df.isExecutable()) { if (df.isExecutable()) {
const QString command = QLatin1String("chmod a+x ") + df.remoteFilePath(); const QString command = QLatin1String("chmod a+x ")
+ Utils::QtcProcess::quoteArgUnix(df.remoteFilePath());
d->chmodProc = connection()->createRemoteProcess(command.toUtf8()); d->chmodProc = connection()->createRemoteProcess(command.toUtf8());
connect(d->chmodProc.data(), SIGNAL(closed(int)), SLOT(handleChmodFinished(int))); connect(d->chmodProc.data(), SIGNAL(closed(int)), SLOT(handleChmodFinished(int)));
connect(d->chmodProc.data(), SIGNAL(readyReadStandardOutput()), connect(d->chmodProc.data(), SIGNAL(readyReadStandardOutput()),
@@ -263,8 +265,9 @@ void GenericDirectUploadService::handleMkdirFinished(int exitStatus)
const QString remoteFilePath = df.remoteDirectory() + QLatin1Char('/') + fi.fileName(); const QString remoteFilePath = df.remoteDirectory() + QLatin1Char('/') + fi.fileName();
if (fi.isSymLink()) { if (fi.isSymLink()) {
const QString target = fi.dir().relativeFilePath(fi.symLinkTarget()); // see QTBUG-5817. const QString target = fi.dir().relativeFilePath(fi.symLinkTarget()); // see QTBUG-5817.
const QString command = QLatin1String("ln -sf ") + target + QLatin1Char(' ') const QStringList args = QStringList() << QLatin1String("ln") << QLatin1String("-sf")
+ remoteFilePath; << target << remoteFilePath;
const QString command = Utils::QtcProcess::joinArgs(args, Utils::OsTypeLinux);
// See comment in SftpChannel::createLink as to why we can't use it. // See comment in SftpChannel::createLink as to why we can't use it.
d->lnProc = connection()->createRemoteProcess(command.toUtf8()); d->lnProc = connection()->createRemoteProcess(command.toUtf8());
@@ -370,7 +373,8 @@ void GenericDirectUploadService::uploadNextFile()
QFileInfo fi = df.localFilePath().toFileInfo(); QFileInfo fi = df.localFilePath().toFileInfo();
if (fi.isDir()) if (fi.isDir())
dirToCreate += QLatin1Char('/') + fi.fileName(); dirToCreate += QLatin1Char('/') + fi.fileName();
const QString command = QLatin1String("mkdir -p ") + dirToCreate; const QString command = QLatin1String("mkdir -p ")
+ Utils::QtcProcess::quoteArgUnix(dirToCreate);
d->mkdirProc = connection()->createRemoteProcess(command.toUtf8()); d->mkdirProc = connection()->createRemoteProcess(command.toUtf8());
connect(d->mkdirProc.data(), SIGNAL(closed(int)), SLOT(handleMkdirFinished(int))); connect(d->mkdirProc.data(), SIGNAL(closed(int)), SLOT(handleMkdirFinished(int)));
connect(d->mkdirProc.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdOutData())); connect(d->mkdirProc.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdOutData()));