UI: Programs: Optimize app info loading

This commit is contained in:
Nodir Temirkhodjaev 2023-01-25 15:07:34 +03:00
parent 2f00e478b4
commit 21597e58c4
5 changed files with 17 additions and 7 deletions

View File

@ -9,5 +9,7 @@ QString AppInfo::filePath(const QString &appPath) const
bool AppInfo::isFileModified(const QString &appPath) const
{
return fileModTime != AppInfoUtil::fileModTime(filePath(appPath));
const auto appFileModTime = AppInfoUtil::fileModTime(filePath(appPath));
return appFileModTime.isValid() && appFileModTime != fileModTime;
}

View File

@ -66,17 +66,22 @@ AppInfo AppInfoCache::appInfo(const QString &appPath)
AppInfo *appInfo = m_cache.object(appPath);
bool lookupRequired = false;
auto appInfoManager = IoC<AppInfoManager>();
if (!appInfo) {
appInfo = new AppInfo();
m_cache.insert(appPath, appInfo, 1);
lookupRequired = true;
} else {
lookupRequired = !appInfoManager->loadInfoFromDb(appPath, *appInfo);
}
if (!lookupRequired) {
lookupRequired = appInfo->isFileModified(appPath);
}
if (lookupRequired) {
IoC<AppInfoManager>()->lookupAppInfo(appPath);
appInfoManager->lookupAppInfo(appPath);
}
return *appInfo;

View File

@ -10,7 +10,7 @@ class AppInfoJob : public WorkerJob
public:
explicit AppInfoJob(const QString &appPath);
QString appPath() const { return text; }
const QString &appPath() const { return text; }
public:
AppInfo appInfo;

View File

@ -182,7 +182,10 @@ bool getInfo(const QString &appPath, AppInfo &appInfo)
// File modification time
appInfo.fileModTime = FileUtil::fileModTime(path);
const bool ok = extractVersionInfo(path, appInfo);
const bool ok = appInfo.fileModTime.isValid();
if (ok) {
extractVersionInfo(path, appInfo);
}
revertWow64FsRedirection(wow64FsRedir);

View File

@ -214,7 +214,7 @@ bool writeFileData(const QString &filePath, const QByteArray &data)
QDateTime fileModTime(const QString &filePath)
{
QFileInfo fi(filePath);
const QFileInfo fi(filePath);
return fi.lastModified(
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
QTimeZone::UTC