From dce7fa842a7df0a95d47419bcedea925cc6d6a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=9C=A3?= Date: Thu, 5 Jun 2025 18:59:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=B4=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谭凯圣 --- ...single_ver_relational_storage_executor.cpp | 10 ++++++++ ...e_single_ver_relational_storage_executor.h | 2 ++ ...ver_relational_storage_executor_extend.cpp | 14 +++++++++++ ...ver_relational_storage_extend_executor.cpp | 9 ++++++- ...eddb_cloud_syncer_download_assets_test.cpp | 24 +++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor.cpp b/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor.cpp index 0f83da86cda..3fbc2422aa7 100644 --- a/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor.cpp +++ b/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor.cpp @@ -1691,6 +1691,16 @@ int SQLiteSingleVerRelationalStorageExecutor::CleanCloudDataAndLogOnUserTable(co return errCode; } +int SQLiteSingleVerRelationalStorageExecutor::GetFlagIsLocalCount(const std::string &logTableName, int32_t &count) +{ + std::string sql = "SELECT count(*) from " + logTableName + " WHERE FLAG&0x02 = 0x02;"; + int errCode = SQLiteUtils::GetCountBySql(dbHandle_, sql, count); + if (errCode != E_OK) { + LOGW("[RDBExecutor] get mark local count from log table failed: %d", errCode); + } + return errCode; +} + int SQLiteSingleVerRelationalStorageExecutor::ChangeCloudDataFlagOnLogTable(const std::string &logTableName) { std::string cleanLogSql = "UPDATE " + logTableName + " SET " + CloudDbConstant::FLAG + " = " + diff --git a/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor.h b/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor.h index 8256f75d462..381a4b8bf4f 100644 --- a/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor.h +++ b/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor.h @@ -526,6 +526,8 @@ private: bool AbortGetDownloadAssetGidIfNeed(const TableSchema &tableSchema, const std::string &gid, bool abortWithLimit, uint32_t &count); + int GetFlagIsLocalCount(const std::string &logTableName, int32_t &count); + static constexpr const char *CONSISTENT_FLAG = "0x20"; static constexpr const char *UPDATE_FLAG_CLOUD = "flag = 0"; static constexpr const char *UPDATE_FLAG_WAIT_COMPENSATED_SYNC = "flag = flag | 0x10"; diff --git a/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor_extend.cpp b/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor_extend.cpp index 2e33253e0ba..7fe5b24f0d0 100644 --- a/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor_extend.cpp +++ b/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_ver_relational_storage_executor_extend.cpp @@ -369,11 +369,18 @@ int SQLiteSingleVerRelationalStorageExecutor::DoCleanLogs(const std::vectorSetTrackerTable(trackerSchema); CallSync({ASSETS_TABLE_NAME}, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, DBStatus::OK); } + +/** + * @tc.name: FillAssetId026 + * @tc.desc: Test if assetId is null when removedevicedata in FLAG_AND_DATA + * @tc.type: FUNC + * @tc.require: + * @tc.author: tankaisheng + */ +HWTEST_F(DistributedDBCloudSyncerDownloadAssetsTest, FillAssetId026, TestSize.Level0) +{ + /** + * @tc.steps:step1. local insert assets and sync, check the local assetId. + * @tc.expected: step1. return OK. + */ + int localCount = 10; + InsertLocalData(db, 0, localCount, ASSETS_TABLE_NAME); + CallSync({ASSETS_TABLE_NAME}, SYNC_MODE_CLOUD_MERGE, DBStatus::OK); + CheckLocaLAssets(ASSETS_TABLE_NAME, "10", {}); + + g_delegate->RemoveDeviceData("", FLAG_AND_DATA); + CheckLocaLAssets(ASSETS_TABLE_NAME, "", {}); + CallSync({ASSETS_TABLE_NAME}, SYNC_MODE_CLOUD_MERGE, DBStatus::OK); + CheckLocaLAssets(ASSETS_TABLE_NAME, "10", {}); +} } // namespace #endif // RELATIONAL_STORE -- Gitee