forked from qt-creator/qt-creator
RemoteLinux: Fix deployment when building remotely
By using a generic file transfer method based of FilePath::copyFile() that doesn't require either of the transfer end point to be the local host. Change-Id: Ia2e4273df52f5ce6533046d96be3f6b521b7f0a5 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -1428,12 +1428,73 @@ private:
|
||||
int m_currentIndex = 0;
|
||||
};
|
||||
|
||||
class GenericTransferImpl : public FileTransferInterface
|
||||
{
|
||||
public:
|
||||
GenericTransferImpl(const FileTransferSetupData &setup, LinuxDevicePrivate *)
|
||||
: FileTransferInterface(setup)
|
||||
{}
|
||||
|
||||
private:
|
||||
void start() final
|
||||
{
|
||||
m_fileCount = m_setup.m_files.size();
|
||||
m_currentIndex = 0;
|
||||
m_checkedDirectories.clear();
|
||||
nextFile();
|
||||
}
|
||||
|
||||
void nextFile()
|
||||
{
|
||||
ProcessResultData result;
|
||||
if (m_currentIndex >= m_fileCount) {
|
||||
emit done(result);
|
||||
return;
|
||||
}
|
||||
|
||||
const FileToTransfer &file = m_setup.m_files.at(m_currentIndex);
|
||||
const FilePath &source = file.m_source;
|
||||
const FilePath &target = file.m_target;
|
||||
++m_currentIndex;
|
||||
|
||||
const FilePath targetDir = target.parentDir();
|
||||
if (!m_checkedDirectories.contains(targetDir)) {
|
||||
emit progress(tr("Creating directory: %1")
|
||||
.arg(targetDir.toUserOutput()));
|
||||
if (!targetDir.ensureWritableDir()) {
|
||||
result.m_errorString = tr("Failed.");
|
||||
result.m_exitCode = -1; // Random pick
|
||||
emit done(result);
|
||||
return;
|
||||
}
|
||||
m_checkedDirectories.insert(targetDir);
|
||||
}
|
||||
|
||||
emit progress(tr("Copying %1/%2: %3 -> %4")
|
||||
.arg(m_currentIndex).arg(m_fileCount).arg(source.toUserOutput(), target.toUserOutput()));
|
||||
if (!source.copyFile(target)) {
|
||||
result.m_errorString = tr("Failed.");
|
||||
result.m_exitCode = -1; // Random pick
|
||||
emit done(result);
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: Use asyncCopyFile instead
|
||||
nextFile();
|
||||
}
|
||||
|
||||
int m_currentIndex = 0;
|
||||
int m_fileCount = 0;
|
||||
QSet<FilePath> m_checkedDirectories;
|
||||
};
|
||||
|
||||
FileTransferInterface *LinuxDevice::createFileTransferInterface(
|
||||
const FileTransferSetupData &setup) const
|
||||
{
|
||||
switch (setup.m_method) {
|
||||
case FileTransferMethod::Sftp: return new SftpTransferImpl(setup, d);
|
||||
case FileTransferMethod::Rsync: return new RsyncTransferImpl(setup, d);
|
||||
case FileTransferMethod::GenericCopy: return new GenericTransferImpl(setup, d);
|
||||
}
|
||||
QTC_CHECK(false);
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user