forked from qt-creator/qt-creator
RemoteLinux: Set up GenericCopy step when sftp and rsync fail
Change-Id: Ia99275c9e1cabe06613a138dec87bd9c2f98b258 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Internal {
|
||||
|
||||
struct TransferStorage
|
||||
{
|
||||
bool sftpWorks = false;
|
||||
bool useGenericCopy = false;
|
||||
};
|
||||
|
||||
class GenericLinuxDeviceTesterPrivate
|
||||
@@ -173,8 +173,10 @@ TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method
|
||||
emit q->progressMessage(Tr::tr("\"%1\" is functional.\n").arg(methodName));
|
||||
if (method == FileTransferMethod::Rsync)
|
||||
m_device->setExtraData(Constants::SupportsRSync, true);
|
||||
else if (method == FileTransferMethod::Sftp)
|
||||
m_device->setExtraData(Constants::SupportsSftp, true);
|
||||
else
|
||||
storage->sftpWorks = true;
|
||||
storage->useGenericCopy = true;
|
||||
};
|
||||
const auto error = [this, method, storage](const FileTransfer &transfer) {
|
||||
const QString methodName = FileTransfer::transferMethodName(method);
|
||||
@@ -189,14 +191,21 @@ TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method
|
||||
.arg(methodName).arg(resultData.m_exitCode).arg(resultData.m_errorString);
|
||||
}
|
||||
emit q->errorMessage(error);
|
||||
if (method == FileTransferMethod::Rsync) {
|
||||
if (method == FileTransferMethod::Rsync)
|
||||
m_device->setExtraData(Constants::SupportsRSync, false);
|
||||
if (!storage->sftpWorks)
|
||||
return;
|
||||
else if (method == FileTransferMethod::Sftp)
|
||||
m_device->setExtraData(Constants::SupportsSftp, false);
|
||||
|
||||
const QVariant supportsRSync = m_device->extraData(Constants::SupportsRSync);
|
||||
const QVariant supportsSftp = m_device->extraData(Constants::SupportsSftp);
|
||||
if (supportsRSync.isValid() && !supportsRSync.toBool()
|
||||
&& supportsSftp.isValid() && !supportsSftp.toBool()) {
|
||||
const QString generic = FileTransfer::transferMethodName(FileTransferMethod::GenericCopy);
|
||||
const QString sftp = FileTransfer::transferMethodName(FileTransferMethod::Sftp);
|
||||
const QString rsync = methodName;
|
||||
const QString rsync = FileTransfer::transferMethodName(FileTransferMethod::Rsync);
|
||||
emit q->progressMessage(Tr::tr("\"%1\" will be used for deployment, because \"%2\" "
|
||||
"is not available.\n").arg(sftp, rsync));
|
||||
"and \"%3\" are not available.\n")
|
||||
.arg(generic, sftp, rsync));
|
||||
}
|
||||
};
|
||||
return TransferTest(setup, done, error);
|
||||
|
@@ -20,6 +20,7 @@ const char CustomCommandDeployStepId[] = "RemoteLinux.GenericRemoteLinuxCustomCo
|
||||
const char KillAppStepId[] = "RemoteLinux.KillAppStep";
|
||||
|
||||
const char SupportsRSync[] = "RemoteLinux.SupportsRSync";
|
||||
const char SupportsSftp[] = "RemoteLinux.SupportsSftp";
|
||||
const char SourceProfile[] = "RemoteLinux.SourceProfile";
|
||||
const char LinkDevice[] = "RemoteLinux.LinkDevice";
|
||||
|
||||
|
@@ -7,15 +7,35 @@
|
||||
#include "remotelinux_constants.h"
|
||||
#include "remotelinuxtr.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/filetransferinterface.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace RemoteLinux::Internal {
|
||||
|
||||
FileTransferMethod defaultTransferMethod(Kit *kit)
|
||||
{
|
||||
auto runDevice = DeviceKitAspect::device(kit);
|
||||
auto buildDevice = BuildDeviceKitAspect::device(kit);
|
||||
|
||||
if (runDevice != buildDevice) {
|
||||
// FIXME: That's not the full truth, we need support from the build
|
||||
// device, too.
|
||||
if (runDevice && runDevice->extraData(Constants::SupportsRSync).toBool())
|
||||
return FileTransferMethod::Rsync;
|
||||
}
|
||||
|
||||
if (runDevice && runDevice->extraData(Constants::SupportsSftp).toBool())
|
||||
return FileTransferMethod::Sftp;
|
||||
|
||||
return FileTransferMethod::GenericCopy;
|
||||
}
|
||||
|
||||
RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory()
|
||||
{
|
||||
setConfigBaseId(RemoteLinux::Constants::DeployToGenericLinux);
|
||||
@@ -40,23 +60,16 @@ RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory()
|
||||
addInitialStep(Constants::MakeInstallStepId, needsMakeInstall);
|
||||
addInitialStep(Constants::KillAppStepId);
|
||||
|
||||
// Todo: Check: Instead of having two different steps here, have one
|
||||
// Todo: Check: Instead of having three different steps here, have one
|
||||
// and shift the logic into the implementation there?
|
||||
addInitialStep(Constants::RsyncDeployStepId, [](Target *target) {
|
||||
auto runDevice = DeviceKitAspect::device(target->kit());
|
||||
auto buildDevice = BuildDeviceKitAspect::device(target->kit());
|
||||
if (runDevice == buildDevice)
|
||||
return false;
|
||||
// FIXME: That's not the full truth, we need support from the build
|
||||
// device, too.
|
||||
return runDevice && runDevice->extraData(Constants::SupportsRSync).toBool();
|
||||
return defaultTransferMethod(target->kit()) == FileTransferMethod::Rsync;
|
||||
});
|
||||
addInitialStep(Constants::DirectUploadStepId, [](Target *target) {
|
||||
auto runDevice = DeviceKitAspect::device(target->kit());
|
||||
auto buildDevice = BuildDeviceKitAspect::device(target->kit());
|
||||
if (runDevice == buildDevice)
|
||||
return true;
|
||||
return runDevice && !runDevice->extraData(Constants::SupportsRSync).toBool();
|
||||
return defaultTransferMethod(target->kit()) == FileTransferMethod::Sftp;
|
||||
});
|
||||
addInitialStep(ProjectExplorer::Constants::COPY_FILE_STEP, [](Target *target) {
|
||||
return defaultTransferMethod(target->kit()) == FileTransferMethod::GenericCopy;
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user