std::vector<std::string> AbstractDBHandler::GetDBPath() {
std::vector<std::string> db_path;
if (db_type_ == DB_TYPE_FILE_PKGDB) {
- db_path = DBHandleProvider::GetInst(uid_).GetParserDBPath();
+ db_path = DBHandleProvider::GetInst(uid_).GetParserDBPath(pid_);
} else if (db_type_ == DB_TYPE_FILE_CERTDB) {
- db_path.emplace_back(DBHandleProvider::GetInst(uid_).GetCertDBPath());
+ db_path.emplace_back(DBHandleProvider::GetInst(uid_).GetCertDBPath(pid_));
}
return db_path;
#include "pkgmgr-info.h"
#include "pkgmgrinfo_debug.h"
+#include <algorithm>
#include <vector>
#ifdef LOG_TAG
return *prov;
}
-std::vector<std::string> DBHandleProvider::GetParserDBPath() {
+std::vector<std::string> DBHandleProvider::GetParserDBPath(int pid) {
std::unique_lock<std::mutex> u(lock_);
std::vector<std::string> db_path_list;
- if (is_memory_) {
+ bool is_file_access = is_memory_;
+ std::vector<int>::iterator it = std::find(pid_list_.begin(),
+ pid_list_.end(), pid);
+ if (it == pid_list_.end())
+ is_file_access = true;
+
+ if (is_file_access) {
db_path_list.emplace_back(parser_memory_db_path_);
if (IsUserRequest(uid_))
db_path_list.emplace_back(global_parser_memory_db_path_);
return db_path_list;
}
-std::string DBHandleProvider::GetCertDBPath() {
+std::string DBHandleProvider::GetCertDBPath(int pid) {
std::unique_lock<std::mutex> u(lock_);
- if (is_memory_)
+ bool is_file_access = is_memory_;
+ std::vector<int>::iterator it = std::find(pid_list_.begin(),
+ pid_list_.end(), pid);
+ if (it == pid_list_.end())
+ is_file_access = true;
+
+ if (is_file_access)
return cert_memory_db_path_;
else
return cert_file_db_path_;
public:
~DBHandleProvider() = default;
static DBHandleProvider& GetInst(uid_t uid);
- std::vector<std::string> GetParserDBPath();
- std::string GetCertDBPath();
+ std::vector<std::string> GetParserDBPath(int pid);
+ std::string GetCertDBPath(int pid);
void SetMemoryMode(bool flag);
private:
std::string cert_memory_db_path_;
std::string cert_file_db_path_;
static bool is_memory_;
+ std::vector<int> pid_list_;
std::mutex lock_;
};