diff options
author | James Addison <jay@jp-hosting.net> | 2024-01-01 19:26:53 +0000 |
---|---|---|
committer | James Addison <jay@jp-hosting.net> | 2024-01-09 13:10:33 +0000 |
commit | b860d48aabfe43d1eb3c9c1c10bd3698d367c255 (patch) | |
tree | 3e590ea7efd1fc410dd101681cbb0c5a062b0ab1 /src/assistant/help/qhelpcollectionhandler.cpp | |
parent | 61b16896caab78252befde88d7697c6bb167b802 (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
Pick-to: 6.6 6.7
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Diffstat (limited to 'src/assistant/help/qhelpcollectionhandler.cpp')
-rw-r--r-- | src/assistant/help/qhelpcollectionhandler.cpp | 6 |
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()) |