Docker: Use shell if possible

Using the shell for short running processes that do not
modify the container environment is recommended as it
avoids starting up another process.

Change-Id: I32a1f348bfa56ee4094599cff1af17525a6d2a98
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2021-10-04 09:42:32 +02:00
parent 8b263b4ae5
commit b7815a4187

View File

@@ -1288,12 +1288,8 @@ QDateTime DockerDevice::lastModified(const FilePath &filePath) const
return res;
}
QtcProcess proc;
proc.setCommand({"stat", {"-c", "%Y", filePath.path()}});
runProcess(proc);
proc.waitForFinished();
const qint64 secs = proc.rawStdOut().toLongLong();
const QString output = d->outputForRunInShell({"stat", {"-c", "%Y", filePath.path()}});
qint64 secs = output.toLongLong();
const QDateTime dt = QDateTime::fromSecsSinceEpoch(secs, Qt::UTC);
return dt;
}
@@ -1615,6 +1611,12 @@ void DockerDevice::aboutToBeRemoved() const
void DockerDevicePrivate::fetchSystemEnviroment()
{
if (m_shell) {
const QString remoteOutput = outputForRunInShell({"env", {}});
m_cachedEnviroment = Environment(remoteOutput.split('\n', Qt::SkipEmptyParts), q->osType());
return;
}
QtcProcess proc;
proc.setCommand({"env", {}});