forked from qt-creator/qt-creator
FileStreamer: Optimize transfer on the same device
Run just "cp" on device instead of transferring the content of the source into local and sending it back again to remote. Change-Id: I703ad1181d77d470ae145691979c34fc75b59a97 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -304,7 +304,21 @@ QTC_DECLARE_CUSTOM_TASK(Writer, Utils::FileStreamWriterAdapter);
|
||||
|
||||
namespace Utils {
|
||||
|
||||
static Group interDeviceTransfer(const FilePath &source, const FilePath &destination)
|
||||
static Group sameRemoteDeviceTransferTask(const FilePath &source, const FilePath &destination)
|
||||
{
|
||||
QTC_CHECK(source.needsDevice());
|
||||
QTC_CHECK(destination.needsDevice());
|
||||
QTC_CHECK(source.isSameDevice(destination));
|
||||
|
||||
const auto setup = [source, destination](QtcProcess &process) {
|
||||
const QStringList args = {source.path(), destination.path()};
|
||||
const FilePath cp = source.withNewPath("cp");
|
||||
process.setCommand({cp, args, OsType::OsTypeLinux});
|
||||
};
|
||||
return {Process(setup)};
|
||||
}
|
||||
|
||||
static Group interDeviceTransferTask(const FilePath &source, const FilePath &destination)
|
||||
{
|
||||
struct TransferStorage { QPointer<FileStreamWriter> writer; };
|
||||
Condition condition;
|
||||
@@ -342,12 +356,19 @@ static Group interDeviceTransfer(const FilePath &source, const FilePath &destina
|
||||
return root;
|
||||
}
|
||||
|
||||
static Group transferTask(const FilePath &source, const FilePath &destination)
|
||||
{
|
||||
if (source.needsDevice() && destination.needsDevice() && source.isSameDevice(destination))
|
||||
return sameRemoteDeviceTransferTask(source, destination);
|
||||
return interDeviceTransferTask(source, destination);
|
||||
}
|
||||
|
||||
static void transfer(QPromise<void> &promise, const FilePath &source, const FilePath &destination)
|
||||
{
|
||||
if (promise.isCanceled())
|
||||
return;
|
||||
|
||||
std::unique_ptr<TaskTree> taskTree(new TaskTree(interDeviceTransfer(source, destination)));
|
||||
std::unique_ptr<TaskTree> taskTree(new TaskTree(transferTask(source, destination)));
|
||||
|
||||
QEventLoop eventLoop;
|
||||
bool finalized = false;
|
||||
|
Reference in New Issue
Block a user