Refactor pkgmgr-info
[platform/core/appfw/pkgmgr-info.git] / src / server / database / cache_db_handler.cc
index aacdbd5..af61c81 100644 (file)
@@ -36,18 +36,17 @@ int CacheDBHandler::Execute() {
   SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
   SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
 
-  std::vector<std::pair<sqlite3*, uid_t>> conn_list;
   if (!Connect()) {
     CacheFlag::SetStatus(CacheFlag::Status::UNPREPARED);
     return PMINFO_R_ERROR;
   }
 
-  conn_list = GetConnection();
+  const auto& conn_list = GetConnection();
   auto lock = CacheFlag::GetWriterLock();
   int ret = PMINFO_R_OK;
-  for (auto& conn : conn_list) {
-    ret = DBHandleProvider::GetInst(conn.second)
-              .UpdateCache(conn.first, GetPID(), uid_, false, GetLocale());
+  for (const auto& [db, uid] : conn_list) {
+    ret = DBHandleProvider::GetInst(uid)
+              .UpdateCache(db, GetPID(), uid_, false, GetLocale());
     if (ret != PMINFO_R_OK) {
       LOG(ERROR) << "Failed to update pkginfo cache : " << ret;
       break;