int pkgmgr_parser_clear_cache_memory_db(void);
int pkgmgr_parser_clear_cache_usr_memory_db(uid_t uid);
+int pkgmgr_parser_update_pending_cache(const char *pkgid);
+
/** @} */
#ifdef __cplusplus
}
{
return pkgmgr_parser_clear_cache_usr_memory_db(__getuid());
}
+
+API int pkgmgr_parser_update_pending_cache(const char *pkgid)
+{
+ return _parser_update_pending_cache(pkgid);
+}
: AbstractParcelable(0, ParcelableType::Command),
uid_(0), cmd_(CommandType::Unknown) {}
-CommandParcelable::CommandParcelable(uid_t uid, CommandType cmd)
- : AbstractParcelable(0, ParcelableType::Command), uid_(uid), cmd_(cmd) {}
+CommandParcelable::CommandParcelable(uid_t uid, CommandType cmd,
+ std::vector<std::string> args)
+ : AbstractParcelable(0, ParcelableType::Command),
+ uid_(uid), cmd_(cmd), args_(std::move(args)) {}
void CommandParcelable::WriteToParcel(tizen_base::Parcel* parcel) const {
AbstractParcelable::WriteToParcel(parcel);
parcel->WriteUInt32(static_cast<int>(uid_));
parcel->WriteUInt32(static_cast<int>(cmd_));
+ parcel->WriteUInt32(static_cast<int>(args_.size()));
+ for (const auto& arg : args_)
+ parcel->WriteString(arg);
}
void CommandParcelable::ReadFromParcel(tizen_base::Parcel* parcel) {
AbstractParcelable::ReadFromParcel(parcel);
- uint32_t cmd, uid;
+ uint32_t cmd, uid, arg_size;
parcel->ReadUInt32(&uid);
uid_ = uid;
parcel->ReadUInt32(&cmd);
cmd_ = static_cast<CommandType>(cmd);
+ parcel->ReadUInt32(&arg_size);
+ for (uint32_t i = 0; i < arg_size; ++i)
+ args_.emplace_back(parcel->ReadString());
}
CommandType CommandParcelable::GetCmd() {
return cmd_;
}
+
void CommandParcelable::SetCmd(CommandType cmd) {
cmd_ = cmd;
}
+const std::vector<std::string>& CommandParcelable::GetArgs() {
+ return args_;
+}
+
} // namespace parcel
} // namespace pkgmgr_common
enum CommandType {
Unknown = -1,
RemoveCache,
+ UpdatePendingCache
};
namespace pkgmgr_common {
class EXPORT_API CommandParcelable : public AbstractParcelable {
public:
CommandParcelable();
- CommandParcelable(uid_t uid, CommandType cmd);
+ CommandParcelable(uid_t uid, CommandType cmd, std::vector<std::string> args);
CommandType GetCmd();
+ const std::vector<std::string>& GetArgs();
void SetCmd(CommandType cmd);
void WriteToParcel(tizen_base::Parcel* parcel) const override;
void ReadFromParcel(tizen_base::Parcel* parcel) override;
private:
uid_t uid_;
CommandType cmd_;
+ std::vector<std::string> args_;
};
} // namespace parcel
extern "C" EXPORT_API int _parser_clear_cache_memory_db(uid_t uid) {
std::shared_ptr<pcp::AbstractParcelable> parcelable(
- new pcp::CommandParcelable(uid, CommandType::RemoveCache));
+ new pcp::CommandParcelable(uid, CommandType::RemoveCache, {}));
pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::COMMAND);
client.GetResultParcel(), pcp::ParcelableType::Result);
}
+extern "C" EXPORT_API int _parser_update_pending_cache(const char* pkgid) {
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::CommandParcelable(_getuid(),
+ CommandType::RemoveCache, { pkgid }));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, _getuid(),
+ pkgmgr_common::ReqType::COMMAND);
+
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ return ValidateParcelable(
+ client.GetResultParcel(), pcp::ParcelableType::Result);
+}
+
static int __create_and_initialize_db(uid_t uid) {
std::shared_ptr<pcp::AbstractParcelable> parcelable(
new pcp::CreateDBParcelable(uid));
int _parser_clear_cache_memory_db(uid_t uid);
+int _parser_update_pending_cache(const char *pkgid);
+
int _parser_create_and_initialize_db(uid_t uid);
#ifdef __cplusplus
return *prov;
}
-std::vector<pid_t> DBHandleProvider::CrashedWriteRequestPIDs() {
+std::unordered_set<pid_t> DBHandleProvider::CrashedWriteRequestPIDs() {
std::unique_lock<std::shared_mutex> u(pid_list_lock_);
if (writer_pid_list_.empty())
return {};
LOG(DEBUG) << "Check process count : " << writer_pid_list_.size();
- std::vector<pid_t> remove_pids;
+ std::unordered_set<pid_t> remove_pids;
for (pid_t pid : writer_pid_list_) {
std::string status_path = "/proc/" + std::to_string(pid) + "/status";
int fd = open(status_path.c_str(), O_RDONLY);
if (fd < 0) {
LOG(ERROR) << "Process is crashed : " << pid;
- remove_pids.push_back(pid);
+ remove_pids.emplace(pid);
} else {
close(fd);
}
}
- for (pid_t pid : remove_pids)
- writer_pid_list_.erase(pid);
-
return remove_pids;
}
int ret = internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
if (ret == PMINFO_R_OK) {
for (auto& [key, val] : pkgs)
- AddPackage(std::move(key), std::move(val));
+ AddPackage(std::move(val));
}
if (!GetModifiedTime(dbpath, &end_time))
}
app->privileges = it->second->privileges;
- std::string appid = app->appid;
- AddApplication(std::move(appid), std::move(app));
+ AddApplication(std::move(app));
}
}
return ret;
}
-void DBHandleProvider::AddPackage(std::string package,
- std::shared_ptr<package_x> info) {
- pkg_map_[package] = std::move(info);
+void DBHandleProvider::AddPackage(std::shared_ptr<package_x> info) {
+ pkg_map_[info->package] = std::move(info);
+}
+
+void DBHandleProvider::AddApplication(std::shared_ptr<application_x> info) {
+ std::string appid = info->appid;
+ std::string pkgid = info->package;
+ app_map_[appid] = std::move(info);
+ pkg_app_map_[pkgid].emplace(std::move(appid));
+}
+
+void DBHandleProvider::ErasePackage(const std::string& pkgid) {
+ auto it = pkg_app_map_.find(pkgid);
+ if (it != pkg_app_map_.end()) {
+ for (const auto& app : it->second)
+ app_map_.erase(app);
+ pkg_app_map_.erase(it);
+ }
+
+ pkg_map_.erase(pkgid);
}
inline bool CheckAppFilters(pkgmgrinfo_filter_x* filter,
return ret;
}
-void DBHandleProvider::AddApplication(std::string app,
- std::shared_ptr<application_x> info) {
- pkg_app_map_[info->package].emplace(app);
- app_map_[app] = std::move(info);
-}
-
-void DBHandleProvider::InsertPID(pid_t pid) {
+void DBHandleProvider::InsertWriterPID(pid_t pid) {
std::unique_lock<std::shared_mutex> u(pid_list_lock_);
writer_pid_list_.insert(pid);
}
-bool DBHandleProvider::ErasePID(pid_t pid) {
+bool DBHandleProvider::EraseWriterPID(pid_t pid) {
std::unique_lock<std::shared_mutex> u(pid_list_lock_);
return writer_pid_list_.erase(pid) == 1;
}
-void DBHandleProvider::RegisterPendingPackageInfo(package_x* info, pid_t pid) {
+void DBHandleProvider::RegisterPendingPackageInfo(
+ const tizen_base::Database& db, package_x* info, pid_t pid, uid_t uid,
+ const std::string& locale, pkgmgr_common::PkgWriteType write_type) {
if (!info || !info->package)
return;
- InsertPID(pid);
+ InsertWriterPID(pid);
- pending_pkg_[pid].emplace(info->package);
-}
+ if (write_type != pkgmgr_common::PkgWriteType::Delete) {
+ pkgmgrinfo_filter_x tmp_filter = { 0, };
+ pkgmgrinfo_node_x node = {
+ .prop = E_PMINFO_PKGINFO_PROP_PACKAGE_ID
+ };
+ tmp_filter.cache_flag = true;
+ tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
+ std::map<std::string, std::shared_ptr<package_x>> pkgs;
-void DBHandleProvider::UpdatePendingPackageInfo(const tizen_base::Database& db,
- const std::vector<pid_t>& pids, uid_t uid, const std::string& locale) {
- pkgmgrinfo_filter_x tmp_filter = { 0, };
- pkgmgrinfo_node_x node = {
- .prop = E_PMINFO_PKGINFO_PROP_PACKAGE_ID
- };
- tmp_filter.cache_flag = true;
- tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
- std::map<std::string, std::shared_ptr<package_x>> pkgs;
- for (const pid_t& pid : pids) {
- for (const auto& pkg : pending_pkg_[pid]) {
- pkg_map_.erase(pkg);
- for (auto& appid : pkg_app_map_[pkg]) {
- app_map_.erase(appid);
+ node.value = const_cast<char*>(info->package);
+ internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
+ node.prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE;
+ for (auto& [pkgid, pkg_handle] : pkgs) {
+ node.value = const_cast<char*>(pkgid.c_str());
+ std::vector<std::shared_ptr<application_x>> app_list;
+ internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
+
+ for (auto& app : app_list) {
+ app->privileges = pkg_handle->privileges;
+ pending_app_[pkgid].emplace_back(std::move(app));
}
- pkg_app_map_.erase(pkg);
- node.value = const_cast<char*>(pkg.c_str());
- internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
+ pending_pkg_[pkgid] = std::make_pair(pid, std::move(pkg_handle));
}
- pending_pkg_.erase(pid);
+ g_slist_free(tmp_filter.list);
+ } else {
+ pending_pkg_[info->package] = std::make_pair(pid, nullptr);
+ pending_app_.erase(info->package);
}
+}
- for (auto& [key, val] : pkgs)
- AddPackage(key, val);
-
- node.prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE;
- for (auto& [key, val] : pkgs) {
- node.value = val->package;
- std::vector<std::shared_ptr<application_x>> app_list;
- internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
+void DBHandleProvider::UpdatePendingPackageInfo(
+ const std::vector<std::string>& pkgids) {
+ for (const auto& pkgid : pkgids) {
+ auto pkg_it = pending_pkg_.find(pkgid);
+ if (pkg_it == pending_pkg_.end())
+ continue;
- for (auto& app : app_list) {
- app->privileges = val->privileges;
- std::string appid = app->appid;
- AddApplication(std::move(appid), std::move(app));
+ ErasePackage(pkgid);
+ auto app_it = pending_app_.find(pkgid);
+ if (app_it != pending_app_.end()) {
+ for (auto& app : app_it->second)
+ AddApplication(std::move(app));
+ pending_app_.erase(app_it);
}
+
+ if (pkg_it->second.second)
+ AddPackage(std::move(pkg_it->second.second));
+
+ EraseWriterPID(pkg_it->second.first);
+ pending_pkg_.erase(pkg_it);
}
+}
- g_slist_free(tmp_filter.list);
+void DBHandleProvider::UpdateCrashedWriterPackageInfo(
+ const std::unordered_set<pid_t>& pids) {
+ for (auto it = pending_pkg_.begin(); it != pending_pkg_.end();) {
+ pid_t pid = it->second.first;
+ if (pids.find(pid) == pids.end()) {
+ it++;
+ continue;
+ }
+
+ const auto& pkgid = it->first;
+ auto old_app_it = pkg_app_map_.find(pkgid);
+ if (old_app_it != pkg_app_map_.end()) {
+ for (const auto& app : old_app_it->second)
+ app_map_.erase(app);
+
+ pkg_app_map_.erase(old_app_it);
+ }
+
+ auto app_it = pending_app_.find(pkgid);
+ if (app_it != pending_app_.end()) {
+ for (auto& app : app_it->second)
+ AddApplication(std::move(app));
+ pending_app_.erase(app_it);
+ }
+
+ AddPackage(std::move(it->second.second));
+ EraseWriterPID(it->second.first);
+ it = pending_pkg_.erase(it);
+ }
}
bool DBHandleProvider::UpdateCachePkg(const tizen_base::Database& db, uid_t uid,
std::map<std::string, std::shared_ptr<package_x>> pkgs;
internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
for (auto& [key, val] : pkgs) {
- AddPackage(key, val);
- for (auto& appid : pkg_app_map_[key]) {
+ AddPackage(val);
+ for (auto& appid : pkg_app_map_[key])
app_map_.erase(appid);
- }
pkg_app_map_.erase(key);
std::vector<std::shared_ptr<application_x>> app_list;
internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
for (auto& app : app_list) {
app->privileges = val->privileges;
- std::string appid = app->appid;
- AddApplication(std::move(appid), std::move(app));
+ AddApplication(std::move(app));
}
}
pkg_app_map_[app->package].erase(app->appid);
app->privileges = it->second->privileges;
- std::string appid = app->appid;
- AddApplication(std::move(appid), std::move(app));
+ AddApplication(std::move(app));
}
return true;
for (auto& app : app_list) {
app->privileges = pkg->privileges;
- std::string appid = app->appid;
- AddApplication(std::move(appid), std::move(app));
+ AddApplication(std::move(app));
}
g_slist_free(tmp_filter.list);
#include <database.hpp>
#include "filter_checker_provider.hh"
+#include "pkg_write_type.hh"
#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_private.h"
#include "shared_object.hh"
public:
~DBHandleProvider() = default;
static DBHandleProvider& GetInst(uid_t uid);
- static std::vector<pid_t> CrashedWriteRequestPIDs();
+ static std::unordered_set<pid_t> CrashedWriteRequestPIDs();
static bool IsWriter(pid_t pid);
std::vector<std::pair<std::string, uid_t>> GetParserDBPath();
std::string GetCertDBPath();
pid_t pid, pkgmgrinfo_filter_x* filter,
const std::string& app);
void TrimCache();
- void RegisterPendingPackageInfo(package_x* info, pid_t pid);
- void UpdatePendingPackageInfo(const tizen_base::Database& db,
- const std::vector<pid_t>& pids, uid_t uid, const std::string& locale);
+ void RegisterPendingPackageInfo(const tizen_base::Database& db,
+ package_x* info, pid_t pid, uid_t uid, const std::string& locale,
+ pkgmgr_common::PkgWriteType write_type);
+ void UpdatePendingPackageInfo(const std::vector<std::string>& pkgids);
+ void UpdateCrashedWriterPackageInfo(const std::unordered_set<pid_t>& pids);
bool UpdateCachePkg(const tizen_base::Database& db, uid_t uid,
const std::string& pkgid, const std::string& locale);
bool UpdateCacheApp(const tizen_base::Database& db, uid_t uid,
private:
explicit DBHandleProvider(uid_t uid);
void ReleaseCache();
- void AddPackage(std::string package, std::shared_ptr<package_x> info);
- void AddApplication(std::string app, std::shared_ptr<application_x> info);
- void InsertPID(pid_t pid);
- bool ErasePID(pid_t pid);
+ void AddPackage(std::shared_ptr<package_x> info);
+ void AddApplication(std::shared_ptr<application_x> info);
+ void ErasePackage(const std::string& pkgid);
+ void InsertWriterPID(pid_t pid);
+ bool EraseWriterPID(pid_t pid);
std::shared_ptr<package_x> GetPackageByApp(const char* appid);
private:
std::unordered_map<std::string, std::shared_ptr<package_x>> pkg_map_;
std::unordered_map<std::string, std::shared_ptr<application_x>> app_map_;
std::unordered_map<std::string, std::unordered_set<std::string>> pkg_app_map_;
- std::unordered_map<pid_t, std::unordered_set<std::string>> pending_pkg_;
+ std::unordered_map<std::string, std::pair<pid_t, std::shared_ptr<package_x>>> pending_pkg_;
+ std::unordered_map<std::string, std::vector<std::shared_ptr<application_x>>> pending_app_;
};
} // namespace database
const auto& db = GetConnection().front().first;
int ret = 0;
- if (write_type_ == pkgmgr_common::PkgWriteType::Insert)
+ if (write_type_ == pkgmgr_common::PkgWriteType::Insert) {
ret = pkgmgr_server::internal::InsertPkgInfo(db, package_, uid_);
- else if (write_type_ == pkgmgr_common::PkgWriteType::Update)
+ } else if (write_type_ == pkgmgr_common::PkgWriteType::Update) {
ret = pkgmgr_server::internal::UpdatePkgInfo(db, package_, uid_);
- else if (write_type_ == pkgmgr_common::PkgWriteType::Delete)
+ } else if (write_type_ == pkgmgr_common::PkgWriteType::Delete) {
ret = pkgmgr_server::internal::DeletePkgInfo(db, package_->package, uid_);
- else
+ } else {
LOG(ERROR) << "Unknown db write type";
+ return PMINFO_R_ERROR;
+ }
if (is_offline_ || ret != PMINFO_R_OK)
return ret;
auto lock = CacheFlag::GetWriterLock();
- if (CacheFlag::GetStatus() == CacheFlag::Status::PREPARED)
- DBHandleProvider::GetInst(uid_)
- .RegisterPendingPackageInfo(package_, GetPID());
+ if (CacheFlag::GetStatus() == CacheFlag::Status::PREPARED) {
+ DBHandleProvider::GetInst(uid_).RegisterPendingPackageInfo(db,
+ package_, GetPID(), uid_, GetLocale(), write_type_);
+ }
return ret;
}
+++ /dev/null
-/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "remove_cache_db_handler.hh"
-
-#include "cache_flag.hh"
-#include "db_handle_provider.hh"
-
-namespace pkgmgr_server {
-namespace database {
-
-RemoveCacheDBHandler::RemoveCacheDBHandler(uid_t uid, std::vector<pid_t> pids)
- : AbstractDBHandler(uid, 0), uid_(uid), pids_(std::move(pids)) {}
-
-int RemoveCacheDBHandler::Execute() {
- std::unique_lock<std::shared_mutex> u(lock_);
- SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
- SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
-
- if (!Connect()) {
- database::DBHandleProvider::GetInst(GetUID()).TrimCache();
- return PMINFO_R_ERROR;
- }
-
- const auto& conn_list = GetConnection();
- auto lock = CacheFlag::GetWriterLock();
- if (CacheFlag::GetStatus() != CacheFlag::Status::PREPARED)
- return PMINFO_R_OK;
-
- CacheFlag::SetStatus(CacheFlag::Status::PREPARING);
- for (const auto& [db, uid] : conn_list) {
- auto& provider = database::DBHandleProvider::GetInst(uid);
- provider.UpdatePendingPackageInfo(db, pids_, uid_, GetLocale());
- }
-
- CacheFlag::SetStatus(CacheFlag::Status::PREPARED);
-
- return PMINFO_R_OK;
-}
-
-} // namespace database
-} // namespace pkgmgr_server
+++ /dev/null
-/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef REMOVE_CACHE_DB_HANDLER_HH_
-#define REMOVE_CACHE_DB_HANDLER_HH_
-
-#include <sys/types.h>
-
-#include <vector>
-
-#include "abstract_db_handler.hh"
-
-namespace pkgmgr_server {
-namespace database {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-class EXPORT_API RemoveCacheDBHandler : public AbstractDBHandler {
- public:
- RemoveCacheDBHandler(uid_t uid, std::vector<pid_t> pids);
- int Execute() override;
-
- private:
- uid_t uid_;
- std::vector<pid_t> pids_;
-};
-
-} // namespace database
-} // namespace pkgmgr_server
-
-#endif // REMOVE_CACHE_DB_HANDLER_HH_
-
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "update_pending_cache_handler.hh"
+
+#include "cache_flag.hh"
+#include "db_handle_provider.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+UpdatePendingCacheHandler::UpdatePendingCacheHandler(uid_t uid, std::unordered_set<pid_t> pids, std::vector<std::string> args)
+ : AbstractDBHandler(uid, 0), uid_(uid), pids_(std::move(pids)), args_(std::move(args)) {}
+
+int UpdatePendingCacheHandler::Execute() {
+ std::unique_lock<std::shared_mutex> u(lock_);
+ SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
+ SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
+
+ if (!Connect()) {
+ database::DBHandleProvider::GetInst(GetUID()).TrimCache();
+ return PMINFO_R_ERROR;
+ }
+
+ const auto& conn_list = GetConnection();
+ auto lock = CacheFlag::GetWriterLock();
+ if (CacheFlag::GetStatus() != CacheFlag::Status::PREPARED)
+ return PMINFO_R_OK;
+
+ CacheFlag::SetStatus(CacheFlag::Status::PREPARING);
+ for (const auto& [db, uid] : conn_list) {
+ auto& provider = database::DBHandleProvider::GetInst(uid);
+ if (!args_.empty())
+ provider.UpdatePendingPackageInfo(args_);
+ else
+ provider.UpdateCrashedWriterPackageInfo(pids_);
+ }
+
+ CacheFlag::SetStatus(CacheFlag::Status::PREPARED);
+
+ return PMINFO_R_OK;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UPDATE_PENDING_CACHE_HANDLER_HH_
+#define UPDATE_PENDING_CACHE_HANDLER_HH_
+
+#include <sys/types.h>
+
+#include <unordered_set>
+#include <vector>
+
+#include "abstract_db_handler.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+class EXPORT_API UpdatePendingCacheHandler : public AbstractDBHandler {
+ public:
+ UpdatePendingCacheHandler(uid_t uid, std::unordered_set<pid_t> pids,
+ std::vector<std::string> args);
+ int Execute() override;
+
+ private:
+ uid_t uid_;
+ std::unordered_set<pid_t> pids_;
+ std::vector<std::string> args_;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // UPDATE_PENDING_CACHE_HANDLER_HH_
+
#include "db_handle_provider.hh"
#include "parcelable_factory.hh"
#include "pkginfo_parcelable.hh"
-#include "remove_cache_db_handler.hh"
+#include "update_pending_cache_handler.hh"
#include "utils/logging.hh"
#include "pkgmgrinfo_debug.h"
return false;
}
- if (parcel->GetCmd() == CommandType::RemoveCache) {
- database::RemoveCacheDBHandler db(parcel->GetUid(), {GetPID()});
+ if (parcel->GetCmd() == CommandType::UpdatePendingCache) {
+ database::UpdatePendingCacheHandler db(parcel->GetUid(), {GetPID()}, parcel->GetArgs());
db.SetLocale(locale);
int ret = db.Execute();
result_ = std::make_shared<pcp::ResultParcelable>(
#include "cynara_checker.hh"
#include "request_handler_factory.hh"
#include "server/database/db_handle_provider.hh"
-#include "server/database/remove_cache_db_handler.hh"
+#include "server/database/update_pending_cache_handler.hh"
#include "utils/logging.hh"
#include "pkgmgrinfo_debug.h"
auto crashed_writer_pids =
database::DBHandleProvider::CrashedWriteRequestPIDs();
if (!crashed_writer_pids.empty()) {
- database::RemoveCacheDBHandler db(getuid(), std::move(crashed_writer_pids));
+ database::UpdatePendingCacheHandler db(getuid(), std::move(crashed_writer_pids), {});
db.SetLocale(h->locale_.GetObject());
db.Execute();
}
TEST_F(ParcelTest, CommandParcelable) {
tizen_base::Parcel parcel;
- pp::CommandParcelable origin_parcelable(0, RemoveCache);
+ pp::CommandParcelable origin_parcelable(0, UpdatePendingCache, {});
pp::CommandParcelable new_parcelable;
parcel.WriteParcelable(origin_parcelable);
parcel.ReadParcelable(&new_parcelable);