mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:55:54 +00:00
UI: Programs: Optimize app info loading
This commit is contained in:
parent
2f00e478b4
commit
21597e58c4
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user