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