diff --git a/ukui-search-app-data-service/app-db-manager.cpp b/ukui-search-app-data-service/app-db-manager.cpp index adb62c8..24b27cd 100644 --- a/ukui-search-app-data-service/app-db-manager.cpp +++ b/ukui-search-app-data-service/app-db-manager.cpp @@ -80,7 +80,7 @@ AppDBManager::AppDBManager(QObject *parent) : QThread(parent), m_database(QSqlDa QStringList appPaths; appPaths << GENERAL_APP_DESKTOP_PATH << ANDROID_APP_DESKTOP_PATH << SNAPD_APP_DESKTOP_PATH << AUTOSTART_APP_DESKTOP_PATH; - refreshAllData2DB(appPaths); + refreshAllData2DB(appPaths, m_dbVersionNeedUpdate); if (m_dbVersionNeedUpdate) { m_dbVersionQsettings->beginGroup(APP_DATABASE_VERSION_VALUE); @@ -363,11 +363,12 @@ bool AppDBManager::addItem2BackIfNotExist(QString itemName, QString itemDataType return res; } -void AppDBManager::refreshAllData2DB(const QStringList &appPaths) +void AppDBManager::refreshAllData2DB(const QStringList &appPaths, bool dbVersionNeedUpdate) { PendingAppInfo items; items.setHandleType(PendingAppInfo::RefreshDataBase); items.setPathsNeedRefreshData(appPaths); + items.setDBUpdate(dbVersionNeedUpdate); PendingAppInfoQueue::getAppInfoQueue().enqueue(items); } @@ -869,7 +870,7 @@ bool AppDBManager::handleLockStateUpdate(const QString &desktopFilePath, int num return res; } -void AppDBManager::handleDataBaseRefresh(const QStringList &appPaths) +void AppDBManager::handleDataBaseRefresh(const QStringList &appPaths, bool dbVersionNeedUpdate) { QMap dataMap; QSqlQuery query(m_database); @@ -925,7 +926,7 @@ void AppDBManager::handleDataBaseRefresh(const QStringList &appPaths) if (!dataMap.isEmpty()) { //数据库有记录 if (dataMap.contains(path)) { - if (!QString::compare(dataMap.value(path), getAppDesktopMd5(path)) && !m_dbVersionNeedUpdate) { + if (!QString::compare(dataMap.value(path), getAppDesktopMd5(path)) && !dbVersionNeedUpdate) { //判断系统语言是否改变 if (m_localeChanged) { this->handleLocaleDataUpdate(path); diff --git a/ukui-search-app-data-service/app-db-manager.h b/ukui-search-app-data-service/app-db-manager.h index 751616f..8e6779b 100644 --- a/ukui-search-app-data-service/app-db-manager.h +++ b/ukui-search-app-data-service/app-db-manager.h @@ -42,7 +42,7 @@ public: static AppDBManager *getInstance(); //刷新数据库数据 - void refreshAllData2DB(const QStringList &appPaths); + void refreshAllData2DB(const QStringList &appPaths, bool dbVersionNeedUpdate = false); //获取desktop文件的md5值 QString getAppDesktopMd5(const QString &desktopfd); @@ -59,7 +59,7 @@ public: bool handleFavoritesStateUpdate(const QString &desktopFilePath, int num, bool isOrderChanged = false); bool handleTopStateUpdate(const QString &desktopFilePath, int num, bool isOrderChanged = false); bool handleLockStateUpdate(const QString &desktopFilePath, int num); - void handleDataBaseRefresh(const QStringList &appPaths); + void handleDataBaseRefresh(const QStringList &appPaths, bool dbVersionNeedUpdate); public Q_SLOTS: //通过pid查找对应的desktop文件 diff --git a/ukui-search-app-data-service/pending-app-info-queue.cpp b/ukui-search-app-data-service/pending-app-info-queue.cpp index d3b2110..0e6df87 100644 --- a/ukui-search-app-data-service/pending-app-info-queue.cpp +++ b/ukui-search-app-data-service/pending-app-info-queue.cpp @@ -146,7 +146,7 @@ void PendingAppInfoQueue::processCache() AppDBManager::getInstance()->handleLocaleDataUpdate(info.path()); break; case PendingAppInfo::RefreshDataBase: - AppDBManager::getInstance()->handleDataBaseRefresh(info.pathsNeedRefreshData()); + AppDBManager::getInstance()->handleDataBaseRefresh(info.pathsNeedRefreshData(), info.dbVersionNeedUpdate()); break; default: break; diff --git a/ukui-search-app-data-service/pending-app-info.h b/ukui-search-app-data-service/pending-app-info.h index 4dc7100..401dd9f 100644 --- a/ukui-search-app-data-service/pending-app-info.h +++ b/ukui-search-app-data-service/pending-app-info.h @@ -48,6 +48,7 @@ public: bool willAddLunchTimes() const {return m_willAddLaunch;} bool isFavoritePosChanged() const {return m_isFavoritePosChanged;} bool isTopPosChanged() const {return m_isTopPosChanged;} + bool dbVersionNeedUpdate() const {return m_dbVersionNeedUpdate;} void setDesktopFp(const QString& desktopfp) {m_desktopfp = desktopfp;} void setHandleType(const PendingAppInfo& info) {m_handleType = info.handleType();} @@ -60,6 +61,7 @@ public: void setChangeFavoritePos(bool isOrderChanged) {m_isFavoritePosChanged = isOrderChanged;} void setChangeTopPos(bool isOrderChanged) {m_isTopPosChanged = isOrderChanged;} void setPathsNeedRefreshData (const QStringList& paths) {m_pathsNeedRefreshData = paths;} + void setDBUpdate(bool versionNeedUpdate) {m_dbVersionNeedUpdate = versionNeedUpdate;} void merge(const PendingAppInfo& info) { m_handleType |= info.handleType(); @@ -94,6 +96,7 @@ private: bool m_isFavoritePosChanged = false; bool m_isTopPosChanged = false; QStringList m_pathsNeedRefreshData; + bool m_dbVersionNeedUpdate = false; }; }