diff options
author | Adam Treat <adam.treat@qt.io> | 2017-10-23 09:42:00 -0400 |
---|---|---|
committer | Adam Treat <adam.treat@qt.io> | 2017-10-25 12:15:05 +0000 |
commit | 3550f5ab96d059ddb2df1a0f74e4dfed142663d1 (patch) | |
tree | 823c3e476f5a98181a4de9d5480f43f67dc308e7 /src/Authoring/Studio/remotedeploymentsender.cpp | |
parent | b49e3e6018809b2c71ddf5ffc3c5865bc31d2135 (diff) |
Optimize the remote deploy
Only send files that have changed since the last update and fix some
issues with state changes on reload.
Task-number: QT3DS-30
Change-Id: I5ba73cedd1a4a279808c4949284eddc98fe4fb0f
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/remotedeploymentsender.cpp')
-rw-r--r-- | src/Authoring/Studio/remotedeploymentsender.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Authoring/Studio/remotedeploymentsender.cpp b/src/Authoring/Studio/remotedeploymentsender.cpp index 3cc7ab2c..b7ed2201 100644 --- a/src/Authoring/Studio/remotedeploymentsender.cpp +++ b/src/Authoring/Studio/remotedeploymentsender.cpp @@ -112,6 +112,7 @@ QPair<QString, int> RemoteDeploymentSender::initConnection() delete m_tcpSocket; m_tcpSocket = new QTcpSocket(this); + m_lastUpdate = QDateTime(); QObject::connect(m_tcpSocket, &QTcpSocket::connected, this, &RemoteDeploymentSender::checkConnection); @@ -182,6 +183,10 @@ void RemoteDeploymentSender::streamProject(const QString &projectFile) return; } + // If we have a new project file, then reset the time + if (projectFile != m_projectFile) + m_lastUpdate = QDateTime(); + const QDir projectDirectory(fileInfo.absolutePath()); // The file to be loaded @@ -194,6 +199,16 @@ void RemoteDeploymentSender::streamProject(const QString &projectFile) while (it.hasNext()) { const QString filePath = it.next(); QFile file(filePath); + + QFileInfo info(file); + QDateTime lastModified = info.lastModified(); +#ifdef Q_OS_DARWIN + // Resolution on macOS is not guaranteed below second granularity + lastModified.addSecs(1); +#endif + if (!m_lastUpdate.isNull() && lastModified < m_lastUpdate) + continue; + if (!file.open(QIODevice::ReadOnly)) { qWarning() << "could not open file " << filePath; return; @@ -213,6 +228,10 @@ void RemoteDeploymentSender::streamProject(const QString &projectFile) metaOut << fileCount; metaOut << relativePath; + // Record the current time to compare against on next update + m_lastUpdate = QDateTime::currentDateTime(); + m_projectFile = projectFile; + m_tcpSocket->write(metaBlock); m_tcpSocket->write(block); } |