diff --git a/services/ans/src/notification_rdb_data_mgr.cpp b/services/ans/src/notification_rdb_data_mgr.cpp index 5b1050346ae7412ab54eb6d67a0764aa62e158e4..9a75b4a6540861cce9df874fad1806417b248707 100644 --- a/services/ans/src/notification_rdb_data_mgr.cpp +++ b/services/ans/src/notification_rdb_data_mgr.cpp @@ -150,6 +150,7 @@ int32_t NotificationDataMgr::InitCreatedTables() createdTables_.insert(tableName); } while (absSharedResultSet->GoToNextRow() == NativeRdb::E_OK); absSharedResultSet->Close(); + ANS_LOGI("create tables successfully"); return NativeRdb::E_OK; } @@ -172,7 +173,7 @@ int32_t NotificationDataMgr::Destroy() ANS_LOGE("failed to destroy db store"); return NativeRdb::E_ERROR; } - ANS_LOGD("destroy db store successfully"); + ANS_LOGI("destroy db store successfully"); return NativeRdb::E_OK; } @@ -718,6 +719,10 @@ int32_t NotificationDataMgr::RestoreForMasterSlaver() NotificationAnalyticsUtil::ReportModifyEvent(message); ANS_LOGI("RestoreForMasterSlaver start"); int32_t result = rdbStore_->Restore(""); + if (result == NativeRdb::E_SQLITE_CORRUPT) { + Destroy(); + Init(); + } ANS_LOGI("RestoreForMasterSlaver result = %{public}d", result); return result; } diff --git a/services/distributed/src/helper/distributed_rdb_helper.cpp b/services/distributed/src/helper/distributed_rdb_helper.cpp index 3064bc7cb37de7cce513192b583f8aede7258985..9a146aaa36d7897d8ea5e3a747e20fca009a2d35 100644 --- a/services/distributed/src/helper/distributed_rdb_helper.cpp +++ b/services/distributed/src/helper/distributed_rdb_helper.cpp @@ -112,6 +112,7 @@ int32_t DistributedRdbHelper::Init() ANS_LOGE("notification rdb init fail"); return NativeRdb::E_ERROR; } + ANS_LOGI("Create rdbStore successfully"); return NativeRdb::E_OK; } @@ -130,7 +131,7 @@ int32_t DistributedRdbHelper::Destroy() ANS_LOGE("failed to destroy db store"); return NativeRdb::E_ERROR; } - ANS_LOGD("destroy db store successfully"); + ANS_LOGI("destroy db store successfully"); return NativeRdb::E_OK; } @@ -333,6 +334,10 @@ int32_t DistributedRdbHelper::RestoreForMasterSlaver() { ANS_LOGI("RestoreForMasterSlaver start"); int32_t result = rdbStore_->Restore(""); + if (result == NativeRdb::E_SQLITE_CORRUPT) { + Destroy(); + Init(); + } ANS_LOGI("RestoreForMasterSlaver result = %{public}d", result); return result; }