forked from qt-creator/qt-creator
SftpFileTransfer: Don't use temporary file for batch file
Use a "-" for a batch file option "-b" what makes sftp read batch from standard input. Fixes: QTCREATORBUG-28167 Change-Id: I449c5ba97ea11fca090b748f0a5ee8099140a548 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -1495,18 +1495,12 @@ private:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_batchFile.reset(new QTemporaryFile(this));
|
QByteArray batchData;
|
||||||
if (!m_batchFile->isOpen() && !m_batchFile->open()) {
|
|
||||||
startFailed(SshTransferInterface::tr("Could not create temporary file: %1")
|
|
||||||
.arg(m_batchFile->errorString()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const FilePaths dirs = dirsToCreate(m_setup.m_files);
|
const FilePaths dirs = dirsToCreate(m_setup.m_files);
|
||||||
for (const FilePath &dir : dirs) {
|
for (const FilePath &dir : dirs) {
|
||||||
if (direction() == FileTransferDirection::Upload) {
|
if (direction() == FileTransferDirection::Upload) {
|
||||||
m_batchFile->write("-mkdir " + ProcessArgs::quoteArgUnix(dir.path()).toLocal8Bit()
|
batchData += "-mkdir " + ProcessArgs::quoteArgUnix(dir.path()).toLocal8Bit() + '\n';
|
||||||
+ '\n');
|
|
||||||
} else if (direction() == FileTransferDirection::Download) {
|
} else if (direction() == FileTransferDirection::Download) {
|
||||||
if (!QDir::root().mkpath(dir.path())) {
|
if (!QDir::root().mkpath(dir.path())) {
|
||||||
startFailed(SshTransferInterface::tr("Failed to create local directory \"%1\".")
|
startFailed(SshTransferInterface::tr("Failed to create local directory \"%1\".")
|
||||||
@@ -1523,25 +1517,22 @@ private:
|
|||||||
const QFileInfo fi(file.m_source.toFileInfo());
|
const QFileInfo fi(file.m_source.toFileInfo());
|
||||||
if (fi.isSymLink()) {
|
if (fi.isSymLink()) {
|
||||||
link = true;
|
link = true;
|
||||||
m_batchFile->write("-rm " + ProcessArgs::quoteArgUnix(
|
batchData += "-rm " + ProcessArgs::quoteArgUnix(
|
||||||
file.m_target.path()).toLocal8Bit() + '\n');
|
file.m_target.path()).toLocal8Bit() + '\n';
|
||||||
// see QTBUG-5817.
|
// see QTBUG-5817.
|
||||||
sourceFileOrLinkTarget.setPath(fi.dir().relativeFilePath(fi.symLinkTarget()));
|
sourceFileOrLinkTarget.setPath(fi.dir().relativeFilePath(fi.symLinkTarget()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_batchFile->write(transferCommand(direction(), link) + ' '
|
batchData += transferCommand(direction(), link) + ' '
|
||||||
+ ProcessArgs::quoteArgUnix(sourceFileOrLinkTarget.path()).toLocal8Bit() + ' '
|
+ ProcessArgs::quoteArgUnix(sourceFileOrLinkTarget.path()).toLocal8Bit() + ' '
|
||||||
+ ProcessArgs::quoteArgUnix(file.m_target.path()).toLocal8Bit() + '\n');
|
+ ProcessArgs::quoteArgUnix(file.m_target.path()).toLocal8Bit() + '\n';
|
||||||
}
|
}
|
||||||
m_batchFile->close();
|
process().setCommand({sftpBinary, fullConnectionOptions() << "-b" << "-" << host()});
|
||||||
process().setCommand(CommandLine(sftpBinary, fullConnectionOptions()
|
process().setWriteData(batchData);
|
||||||
<< "-b" << m_batchFile->fileName() << host()));
|
|
||||||
process().start();
|
process().start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void doneImpl() final { handleDone(); }
|
void doneImpl() final { handleDone(); }
|
||||||
|
|
||||||
std::unique_ptr<QTemporaryFile> m_batchFile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsyncTransferImpl : public SshTransferInterface
|
class RsyncTransferImpl : public SshTransferInterface
|
||||||
|
Reference in New Issue
Block a user