diff --git a/src/ui/appinfo/appinfo.cpp b/src/ui/appinfo/appinfo.cpp index f16e78cf..d730dc58 100644 --- a/src/ui/appinfo/appinfo.cpp +++ b/src/ui/appinfo/appinfo.cpp @@ -2,7 +2,12 @@ #include "appinfoutil.h" +QString AppInfo::getPath(const QString &appPath) const +{ + return !altPath.isEmpty() ? altPath : appPath; +} + bool AppInfo::isFileModified(const QString &appPath) const { - return fileModTime != AppInfoUtil::fileModTime(appPath); + return fileModTime != AppInfoUtil::fileModTime(getPath(appPath)); } diff --git a/src/ui/appinfo/appinfo.h b/src/ui/appinfo/appinfo.h index 80fe360e..0b0125ad 100644 --- a/src/ui/appinfo/appinfo.h +++ b/src/ui/appinfo/appinfo.h @@ -7,6 +7,7 @@ class AppInfo { public: + QString getPath(const QString &appPath) const; bool isFileModified(const QString &appPath) const; bool isValid() const { return iconId != 0; } @@ -16,6 +17,7 @@ public: QDateTime fileModTime; + QString altPath; QString fileDescription; QString companyName; QString productName; diff --git a/src/ui/appinfo/appinfomanager.cpp b/src/ui/appinfo/appinfomanager.cpp index 694fff84..507e76e9 100644 --- a/src/ui/appinfo/appinfomanager.cpp +++ b/src/ui/appinfo/appinfomanager.cpp @@ -16,13 +16,13 @@ Q_LOGGING_CATEGORY(CLOG_APPINFO_MANAGER, "appInfo") #define logWarning() qCWarning(CLOG_APPINFO_MANAGER, ) #define logCritical() qCCritical(CLOG_APPINFO_MANAGER, ) -#define DATABASE_USER_VERSION 3 +#define DATABASE_USER_VERSION 4 #define APP_CACHE_MAX_COUNT 2000 namespace { -const char *const sqlSelectAppInfo = "SELECT file_descr, company_name," +const char *const sqlSelectAppInfo = "SELECT alt_path, file_descr, company_name," " product_name, product_ver, file_mod_time, icon_id" " FROM app WHERE path = ?1;"; @@ -41,10 +41,10 @@ const char *const sqlUpdateIconRefCount = "UPDATE icon" " SET ref_count = ref_count + ?2" " WHERE icon_id = ?1;"; -const char *const sqlInsertAppInfo = "INSERT INTO app(path, file_descr, company_name," +const char *const sqlInsertAppInfo = "INSERT INTO app(path, alt_path, file_descr, company_name," " product_name, product_ver, file_mod_time," " icon_id, access_time)" - " VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7, datetime('now'));"; + " VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, datetime('now'));"; const char *const sqlSelectAppCount = "SELECT count(*) FROM app;"; @@ -123,9 +123,9 @@ bool AppInfoManager::loadInfoFromFs(const QString &appPath, AppInfo &appInfo) return AppInfoUtil::getInfo(appPath, appInfo); } -QImage AppInfoManager::loadIconFromFs(const QString &appPath) +QImage AppInfoManager::loadIconFromFs(const QString &appPath, const AppInfo &appInfo) { - return AppInfoUtil::getIcon(appPath); + return AppInfoUtil::getIcon(appInfo.getPath(appPath)); } bool AppInfoManager::loadInfoFromDb(const QString &appPath, AppInfo &appInfo) @@ -145,12 +145,13 @@ bool AppInfoManager::loadInfoFromDb(const QString &appPath, AppInfo &appInfo) if (stmt.step() != SqliteStmt::StepRow) return false; - appInfo.fileDescription = stmt.columnText(0); - appInfo.companyName = stmt.columnText(1); - appInfo.productName = stmt.columnText(2); - appInfo.productVersion = stmt.columnText(3); - appInfo.fileModTime = stmt.columnDateTime(4); - appInfo.iconId = stmt.columnInt64(5); + appInfo.altPath = stmt.columnText(0); + appInfo.fileDescription = stmt.columnText(1); + appInfo.companyName = stmt.columnText(2); + appInfo.productName = stmt.columnText(3); + appInfo.productVersion = stmt.columnText(4); + appInfo.fileModTime = stmt.columnDateTime(5); + appInfo.iconId = stmt.columnInt64(6); // Update last access time updateAppAccessTime(appPath); @@ -202,8 +203,8 @@ bool AppInfoManager::saveToDb(const QString &appPath, AppInfo &appInfo, const QI // Save version info if (ok) { const QVariantList vars = QVariantList() - << appPath << appInfo.fileDescription << appInfo.companyName << appInfo.productName - << appInfo.productVersion << appInfo.fileModTime << iconId; + << appPath << appInfo.altPath << appInfo.fileDescription << appInfo.companyName + << appInfo.productName << appInfo.productVersion << appInfo.fileModTime << iconId; sqliteDb()->executeEx(sqlInsertAppInfo, vars, 0, &ok); } diff --git a/src/ui/appinfo/appinfomanager.h b/src/ui/appinfo/appinfomanager.h index e6dcf25d..076b79c0 100644 --- a/src/ui/appinfo/appinfomanager.h +++ b/src/ui/appinfo/appinfomanager.h @@ -26,7 +26,7 @@ public: void setUp() override; bool loadInfoFromFs(const QString &appPath, AppInfo &appInfo); - QImage loadIconFromFs(const QString &appPath); + QImage loadIconFromFs(const QString &appPath, const AppInfo &appInfo); bool loadInfoFromDb(const QString &appPath, AppInfo &appInfo); QImage loadIconFromDb(qint64 iconId); diff --git a/src/ui/appinfo/appinfoutil.cpp b/src/ui/appinfo/appinfoutil.cpp index 1c9350f9..68def7d4 100644 --- a/src/ui/appinfo/appinfoutil.cpp +++ b/src/ui/appinfo/appinfoutil.cpp @@ -173,6 +173,7 @@ bool getInfo(const QString &appPath, AppInfo &appInfo) QString serviceName; if (FileUtil::isSvcHostService(appPath, serviceName)) { path = ServiceInfoManager::getSvcHostServiceDll(serviceName); + appInfo.altPath = path; } const auto wow64FsRedir = disableWow64FsRedirection(); @@ -202,16 +203,9 @@ QImage getIcon(const QString &appPath) return QImage(":/icons/windows-48.png"); } - QString path = appPath; - - QString serviceName; - if (FileUtil::isSvcHostService(appPath, serviceName)) { - path = ServiceInfoManager::getSvcHostServiceDll(serviceName); - } - const auto wow64FsRedir = disableWow64FsRedirection(); - const QImage result = extractShellIcon(path); + const QImage result = extractShellIcon(appPath); revertWow64FsRedirection(wow64FsRedir); @@ -241,6 +235,9 @@ bool fileExists(const QString &appPath) QDateTime fileModTime(const QString &appPath) { + if (appPath.isEmpty() || FileUtil::isSystemApp(appPath)) + return {}; + const auto wow64FsRedir = disableWow64FsRedirection(); const QDateTime res = FileUtil::fileModTime(appPath); diff --git a/src/ui/appinfo/appinfoworker.cpp b/src/ui/appinfo/appinfoworker.cpp index a4ab6b52..fb431ee8 100644 --- a/src/ui/appinfo/appinfoworker.cpp +++ b/src/ui/appinfo/appinfoworker.cpp @@ -40,7 +40,7 @@ void AppInfoWorker::doJob(WorkerJob *workerJob) // Try to load from FS if (!loadedFromDb && manager()->loadInfoFromFs(appPath, appInfo)) { - const QImage appIcon = manager()->loadIconFromFs(appPath); + const QImage appIcon = manager()->loadIconFromFs(appPath, appInfo); manager()->saveToDb(appPath, appInfo, appIcon); } diff --git a/src/ui/appinfo/migrations/1.sql b/src/ui/appinfo/migrations/1.sql index 37267c91..099f86af 100644 --- a/src/ui/appinfo/migrations/1.sql +++ b/src/ui/appinfo/migrations/1.sql @@ -1,5 +1,6 @@ CREATE TABLE app( path TEXT PRIMARY KEY, + alt_path TEXT, file_descr TEXT, company_name TEXT, product_name TEXT,