forked from qt-creator/qt-creator
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:
@@ -1288,12 +1288,8 @@ QDateTime DockerDevice::lastModified(const FilePath &filePath) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
QtcProcess proc;
|
const QString output = d->outputForRunInShell({"stat", {"-c", "%Y", filePath.path()}});
|
||||||
proc.setCommand({"stat", {"-c", "%Y", filePath.path()}});
|
qint64 secs = output.toLongLong();
|
||||||
runProcess(proc);
|
|
||||||
proc.waitForFinished();
|
|
||||||
|
|
||||||
const qint64 secs = proc.rawStdOut().toLongLong();
|
|
||||||
const QDateTime dt = QDateTime::fromSecsSinceEpoch(secs, Qt::UTC);
|
const QDateTime dt = QDateTime::fromSecsSinceEpoch(secs, Qt::UTC);
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
@@ -1615,6 +1611,12 @@ void DockerDevice::aboutToBeRemoved() const
|
|||||||
|
|
||||||
void DockerDevicePrivate::fetchSystemEnviroment()
|
void DockerDevicePrivate::fetchSystemEnviroment()
|
||||||
{
|
{
|
||||||
|
if (m_shell) {
|
||||||
|
const QString remoteOutput = outputForRunInShell({"env", {}});
|
||||||
|
m_cachedEnviroment = Environment(remoteOutput.split('\n', Qt::SkipEmptyParts), q->osType());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QtcProcess proc;
|
QtcProcess proc;
|
||||||
proc.setCommand({"env", {}});
|
proc.setCommand({"env", {}});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user