summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Addison <jay@jp-hosting.net>2024-01-01 19:26:53 +0000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-01-10 05:02:30 +0000
commitcce0eee3211192ae3cbab79fd120bfa833a5caea (patch)
tree88ed41b2c6329365d598df83a11ae5d697665a14
parentd48e450b401679c9fbfbd49ca0620b8716f43eb9 (diff)
qhelpgenerator: read file modification time in UTC
During help collection construction when the SOURCE_DATE_EPOCH[1] environment variable is set, each file modification timestamp recorded in the TimeStampTable is clamped (capped) to a maximum of the value specified in the environment variable. The SOURCE_DATE_EPOCH value is an offset in seconds from the Unix epoch, and is relative to the UTC timezone. Therefore we can avoid some timezone conversion operations and make it clearer in the code that we are comparing UTC-with-UTC by adding a timezone argument[2] of UTC when calling lastModified to retrieve the modification timestamp for each file. This argument is available in Qt 6.6 onwards. This change is not intended to produce any functional change in the behavior of the code; instead readability/comprehensibility and, to a lesser extent, a performance benefit described by QTBUG-100349 when reading UTC-native filesystem timestamps are the two reasons behind this change. [1] - https://reproducible-builds.org/specs/source-date-epoch/ [2] - https://doc.qt.io/qt-6.6/qfileinfo.html#lastModified-1 Task-number: QTBUG-62697 Change-Id: Iffb1aed5ee326ed40acb6285078c6682f76750c8 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Kai Köhne <kai.koehne@qt.io> (cherry picked from commit b860d48aabfe43d1eb3c9c1c10bd3698d367c255) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit e2e750bfaa32362c8d9730fbd2bd35663722792f)
-rw-r--r--src/assistant/help/qhelpcollectionhandler.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/assistant/help/qhelpcollectionhandler.cpp b/src/assistant/help/qhelpcollectionhandler.cpp
index a79b8dacb..1116f750f 100644
--- a/src/assistant/help/qhelpcollectionhandler.cpp
+++ b/src/assistant/help/qhelpcollectionhandler.cpp
@@ -2165,15 +2165,13 @@ bool QHelpCollectionHandler::registerIndexTable(const QHelpDBReader::IndexTable
m_query->addBindValue(fileName);
const QFileInfo fi(absoluteDocPath(fileName));
m_query->addBindValue(fi.size());
- QDateTime lastModified = fi.lastModified();
+ QDateTime lastModified = fi.lastModified(QTimeZone::UTC);
if (qEnvironmentVariableIsSet("SOURCE_DATE_EPOCH")) {
const QString sourceDateEpochStr = qEnvironmentVariable("SOURCE_DATE_EPOCH");
bool ok;
const qlonglong sourceDateEpoch = sourceDateEpochStr.toLongLong(&ok);
- if (ok && sourceDateEpoch < lastModified.toSecsSinceEpoch()) {
- lastModified.setTimeZone(QTimeZone::UTC);
+ if (ok && sourceDateEpoch < lastModified.toSecsSinceEpoch())
lastModified.setSecsSinceEpoch(sourceDateEpoch);
- }
}
m_query->addBindValue(lastModified.toString(Qt::ISODate));
if (!m_query->exec())