CacheDBHandler::~CacheDBHandler() {}
+bool CacheDBHandler::IsBackupDBExist() {
+ auto dbpath_list = GetDBPath();
+ for (const auto& [path, uid] : dbpath_list) {
+ auto backup_db_path = path + ".bck";
+
+ if (access(backup_db_path.c_str(), F_OK) == 0) {
+ LOG(WARNING) << "Backup database[" << backup_db_path
+ << "] created during pkg_upgrade remain, Try to delay cache creation";
+ return true;
+ }
+ }
+
+ return false;
+}
+
int CacheDBHandler::Execute() {
- std::shared_lock<std::shared_mutex> s(lock_);
SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
+ while (IsBackupDBExist())
+ sleep(1);
+
+ std::shared_lock<std::shared_mutex> s(lock_);
+
if (!Connect()) {
CacheFlag::SetStatus(CacheFlag::Status::UNPREPARED);
return PMINFO_R_ERROR;