From a2b8cdfe845d4c22f4118d2ca93501a39443c5c7 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Thu, 5 Jan 2023 11:15:51 +0300 Subject: [PATCH] UI: FileUtil::fileModTime: Use QFileInfo's file times in UTC .. because it's faster. --- src/ui/appinfo/appinfoutil.cpp | 19 ++++++++++--------- src/ui/task/taskzonedownloader.cpp | 6 ++++-- src/ui/util/fileutil.cpp | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/ui/appinfo/appinfoutil.cpp b/src/ui/appinfo/appinfoutil.cpp index 56be5212..33fa33d7 100644 --- a/src/ui/appinfo/appinfoutil.cpp +++ b/src/ui/appinfo/appinfoutil.cpp @@ -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; } diff --git a/src/ui/task/taskzonedownloader.cpp b/src/ui/task/taskzonedownloader.cpp index 21a3f713..e086b091 100644 --- a/src/ui/task/taskzonedownloader.cpp +++ b/src/ui/task/taskzonedownloader.cpp @@ -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; } diff --git a/src/ui/util/fileutil.cpp b/src/ui/util/fileutil.cpp index f946132b..351def9a 100644 --- a/src/ui/util/fileutil.cpp +++ b/src/ui/util/fileutil.cpp @@ -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)