GenericDirectUploadService: Don't use SshRemoteProcess

Use QtcProcess with a path on device instead.

Change-Id: I61c6b2cf042a223a037109b56418dbf76dbad161
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-05-02 21:53:02 +02:00
parent ece39c7c2f
commit 23cc03b470
2 changed files with 15 additions and 14 deletions

View File

@@ -26,12 +26,12 @@
#include "genericdirectuploadservice.h" #include "genericdirectuploadservice.h"
#include <projectexplorer/deployablefile.h> #include <projectexplorer/deployablefile.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#include <ssh/sftptransfer.h> #include <ssh/sftptransfer.h>
#include <ssh/sshconnection.h> #include <ssh/sshconnection.h>
#include <ssh/sshremoteprocess.h>
#include <QDateTime> #include <QDateTime>
#include <QDir> #include <QDir>
@@ -55,7 +55,7 @@ const int MaxConcurrentStatCalls = 10;
class GenericDirectUploadServicePrivate class GenericDirectUploadServicePrivate
{ {
public: public:
DeployableFile getFileForProcess(SshRemoteProcess *proc) DeployableFile getFileForProcess(QtcProcess *proc)
{ {
const auto it = remoteProcs.find(proc); const auto it = remoteProcs.find(proc);
QTC_ASSERT(it != remoteProcs.end(), return DeployableFile()); QTC_ASSERT(it != remoteProcs.end(), return DeployableFile());
@@ -66,7 +66,7 @@ public:
IncrementalDeployment incremental = IncrementalDeployment::NotSupported; IncrementalDeployment incremental = IncrementalDeployment::NotSupported;
bool ignoreMissingFiles = false; bool ignoreMissingFiles = false;
QHash<SshRemoteProcess *, DeployableFile> remoteProcs; QHash<QtcProcess *, DeployableFile> remoteProcs;
QQueue<DeployableFile> filesToStat; QQueue<DeployableFile> filesToStat;
State state = Inactive; State state = Inactive;
QList<DeployableFile> filesToUpload; QList<DeployableFile> filesToUpload;
@@ -135,7 +135,7 @@ void GenericDirectUploadService::doDeploy()
} }
QDateTime GenericDirectUploadService::timestampFromStat(const DeployableFile &file, QDateTime GenericDirectUploadService::timestampFromStat(const DeployableFile &file,
SshRemoteProcess *statProc, QtcProcess *statProc,
const QString &errorMsg) const QString &errorMsg)
{ {
QString errorDetails; QString errorDetails;
@@ -197,9 +197,10 @@ void GenericDirectUploadService::stopDeployment()
void GenericDirectUploadService::runStat(const DeployableFile &file) void GenericDirectUploadService::runStat(const DeployableFile &file)
{ {
// We'd like to use --format=%Y, but it's not supported by busybox. // We'd like to use --format=%Y, but it's not supported by busybox.
const QString statCmd = "stat -t " + Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath()); QtcProcess * const statProc = new QtcProcess(this);
SshRemoteProcess * const statProc = connection()->createRemoteProcess(statCmd).release(); const CommandLine statCmd {deviceConfiguration()->mapToGlobalPath("stat"),
statProc->setParent(this); {"-t", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}};
statProc->setCommand(statCmd);
connect(statProc, &QtcProcess::done, this, [this, statProc, state = d->state] { connect(statProc, &QtcProcess::done, this, [this, statProc, state = d->state] {
QTC_ASSERT(d->state == state, return); QTC_ASSERT(d->state == state, return);
const DeployableFile file = d->getFileForProcess(statProc); const DeployableFile file = d->getFileForProcess(statProc);
@@ -336,11 +337,10 @@ void GenericDirectUploadService::chmod()
for (const DeployableFile &f : qAsConst(d->filesToUpload)) { for (const DeployableFile &f : qAsConst(d->filesToUpload)) {
if (!f.isExecutable()) if (!f.isExecutable())
continue; continue;
const QString command = QLatin1String("chmod a+x ") QtcProcess * const chmodProc = new QtcProcess(this);
+ Utils::ProcessArgs::quoteArgUnix(f.remoteFilePath()); const CommandLine chmodCmd {deviceConfiguration()->mapToGlobalPath("chmod"),
SshRemoteProcess * const chmodProc {"a+x", Utils::ProcessArgs::quoteArgUnix(f.remoteFilePath())}};
= connection()->createRemoteProcess(command).release(); chmodProc->setCommand(chmodCmd);
chmodProc->setParent(this);
connect(chmodProc, &QtcProcess::done, this, [this, chmodProc, state = d->state] { connect(chmodProc, &QtcProcess::done, this, [this, chmodProc, state = d->state] {
QTC_ASSERT(state == d->state, return); QTC_ASSERT(state == d->state, return);
const DeployableFile file = d->getFileForProcess(chmodProc); const DeployableFile file = d->getFileForProcess(chmodProc);

View File

@@ -36,7 +36,8 @@ QT_FORWARD_DECLARE_CLASS(QDateTime)
QT_FORWARD_DECLARE_CLASS(QString) QT_FORWARD_DECLARE_CLASS(QString)
namespace ProjectExplorer { class DeployableFile; } namespace ProjectExplorer { class DeployableFile; }
namespace QSsh { class SshRemoteProcess; } namespace Utils { class QtcProcess; }
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { class GenericDirectUploadServicePrivate; } namespace Internal { class GenericDirectUploadServicePrivate; }
@@ -65,7 +66,7 @@ protected:
private: private:
void runStat(const ProjectExplorer::DeployableFile &file); void runStat(const ProjectExplorer::DeployableFile &file);
QDateTime timestampFromStat(const ProjectExplorer::DeployableFile &file, QDateTime timestampFromStat(const ProjectExplorer::DeployableFile &file,
QSsh::SshRemoteProcess *statProc, const QString &errorMsg); Utils::QtcProcess *statProc, const QString &errorMsg);
void checkForStateChangeOnRemoteProcFinished(); void checkForStateChangeOnRemoteProcFinished();
QList<ProjectExplorer::DeployableFile> collectFilesToUpload( QList<ProjectExplorer::DeployableFile> collectFilesToUpload(