UI: FileUtil::fileModTime: Use QFileInfo's file times in UTC

.. because it's faster.
This commit is contained in:
Nodir Temirkhodjaev 2023-01-05 11:15:51 +03:00
parent 3f38f86b61
commit a2b8cdfe84
3 changed files with 15 additions and 12 deletions

View File

@ -151,6 +151,12 @@ bool extractVersionInfo(const QString &appPath, AppInfo &appInfo)
appInfo.productName = extractInfoText(infoData, langInfo, L"ProductName");
appInfo.fileDescription = extractInfoText(infoData, langInfo, L"FileDescription");
// File description
if (appInfo.fileDescription.isEmpty()) {
appInfo.fileDescription =
!appInfo.productName.isEmpty() ? appInfo.productName : FileUtil::fileName(appPath);
}
return true;
}
@ -170,6 +176,7 @@ bool getInfo(const QString &appPath, AppInfo &appInfo)
QString path = appPath;
// Service Name: Set real path
QString serviceName;
if (FileUtil::isSvcHostService(appPath, serviceName)) {
path = ServiceInfoManager::getSvcHostServiceDll(serviceName);
@ -178,19 +185,13 @@ bool getInfo(const QString &appPath, AppInfo &appInfo)
const auto wow64FsRedir = disableWow64FsRedirection();
// File modification time
appInfo.fileModTime = FileUtil::fileModTime(path);
const bool ok = extractVersionInfo(path, appInfo);
revertWow64FsRedirection(wow64FsRedir);
// File description
if (appInfo.fileDescription.isEmpty()) {
appInfo.fileDescription =
!appInfo.productName.isEmpty() ? appInfo.productName : FileUtil::fileName(path);
}
// File modification time
appInfo.fileModTime = FileUtil::fileModTime(path);
return ok;
}

View File

@ -57,10 +57,12 @@ void TaskZoneDownloader::loadLocalFile()
{
bool success = false;
if (sourceModTime() != FileUtil::fileModTime(url())
|| !FileUtil::fileExists(cacheFileBinPath())) {
const auto fileModTime = FileUtil::fileModTime(url());
if (sourceModTime() != fileModTime || !FileUtil::fileExists(cacheFileBinPath())) {
const auto buffer = FileUtil::readFileData(url());
downloader()->setBuffer(buffer);
setSourceModTime(fileModTime);
success = true;
}

View File

@ -215,7 +215,7 @@ bool writeFileData(const QString &filePath, const QByteArray &data)
QDateTime fileModTime(const QString &filePath)
{
QFileInfo fi(filePath);
return fi.lastModified();
return fi.lastModified(QTimeZone::UTC);
}
QString expandPath(const QString &path)