GenericDirectUploadService: Use FileTransfer

Instead of using SftpTransfer.

Change-Id: I0732e1472efe3db10291078319b23211973c86d2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-05-10 16:50:14 +02:00
parent 4076f6c385
commit 92f20c5711
2 changed files with 18 additions and 21 deletions

View File

@@ -24,14 +24,13 @@
****************************************************************************/
#include "genericdirectuploadservice.h"
#include "linuxdevice.h"
#include <projectexplorer/deployablefile.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <utils/hostosinfo.h>
#include <utils/processinterface.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <ssh/sftptransfer.h>
#include <ssh/sshconnection.h>
#include <QDateTime>
#include <QDir>
@@ -70,7 +69,7 @@ public:
QQueue<DeployableFile> filesToStat;
State state = Inactive;
QList<DeployableFile> filesToUpload;
SftpTransferPtr uploader;
std::unique_ptr<FileTransfer> uploader;
QList<DeployableFile> deployableFiles;
};
@@ -251,11 +250,7 @@ void GenericDirectUploadService::setFinished()
it.key()->terminate();
}
d->remoteProcs.clear();
if (d->uploader) {
d->uploader->disconnect();
d->uploader->stop();
d->uploader.release()->deleteLater();
}
d->uploader->stop();
d->filesToUpload.clear();
}
@@ -293,11 +288,11 @@ void GenericDirectUploadService::uploadFiles()
return;
}
emit progressMessage(tr("%n file(s) need to be uploaded.", "", d->filesToUpload.size()));
FilesToTransfer filesToTransfer;
for (const DeployableFile &f : qAsConst(d->filesToUpload)) {
if (!f.localFilePath().exists()) {
FilesToTransfer files;
for (const DeployableFile &file : qAsConst(d->filesToUpload)) {
if (!file.localFilePath().exists()) {
const QString message = tr("Local file \"%1\" does not exist.")
.arg(f.localFilePath().toUserOutput());
.arg(file.localFilePath().toUserOutput());
if (d->ignoreMissingFiles) {
emit warningMessage(message);
continue;
@@ -308,13 +303,17 @@ void GenericDirectUploadService::uploadFiles()
return;
}
}
filesToTransfer << FileToTransfer(f.localFilePath().toString(), f.remoteFilePath());
files.append({file.localFilePath(),
deviceConfiguration()->filePath(file.remoteFilePath())});
}
d->uploader = connection()->createUpload(filesToTransfer);
connect(d->uploader.get(), &SftpTransfer::done, [this](const QString &error) {
LinuxDevice::ConstPtr linuxDevice = deviceConfiguration().dynamicCast<const LinuxDevice>();
QTC_ASSERT(linuxDevice, return);
d->uploader.reset(linuxDevice->createFileTransfer(files));
connect(d->uploader.get(), &FileTransfer::done, this, [this](const ProcessResultData &result) {
QTC_ASSERT(d->state == Uploading, return);
if (!error.isEmpty()) {
emit errorMessage(error);
if (result.m_error != QProcess::UnknownError) {
emit errorMessage(result.m_errorString);
setFinished();
handleDeploymentDone();
return;
@@ -323,7 +322,7 @@ void GenericDirectUploadService::uploadFiles()
chmod();
queryFiles();
});
connect(d->uploader.get(), &SftpTransfer::progress,
connect(d->uploader.get(), &FileTransfer::progress,
this, &GenericDirectUploadService::progressMessage);
d->uploader->start();
}

View File

@@ -28,8 +28,6 @@
#include "abstractremotelinuxdeployservice.h"
#include "remotelinux_export.h"
#include <ssh/sftpdefs.h>
#include <QList>
QT_FORWARD_DECLARE_CLASS(QDateTime)