From 42edc3f3f044f35de79616622f7d91d62ac9f49d Mon Sep 17 00:00:00 2001 From: zuojiangjiang Date: Thu, 4 May 2023 14:10:08 +0800 Subject: [PATCH] update Signed-off-by: zuojiangjiang --- .../framework/cloud/cloud_info.cpp | 12 +++++++++--- .../framework/include/cloud/cloud_info.h | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/datamgr_service/services/distributeddataservice/framework/cloud/cloud_info.cpp b/datamgr_service/services/distributeddataservice/framework/cloud/cloud_info.cpp index d3560bb8..2f44ff85 100644 --- a/datamgr_service/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/datamgr_service/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -68,15 +68,21 @@ std::map CloudInfo::GetSchemaKey() const { std::map keys; for (const auto &app : apps) { - const auto key = GetKey(SCHEMA_PREFIX, { std::to_string(user), id, app.bundleName }); + const auto key = GetKey( + SCHEMA_PREFIX, { std::to_string(user), app.bundleName, std::to_string(app.instanceId) }); keys.insert_or_assign(app.bundleName, key); } return keys; } -std::string CloudInfo::GetSchemaKey(std::string bundleName) const +std::string CloudInfo::GetSchemaKey(const std::string &bundleName, const int32_t instanceId) const { - return GetKey(SCHEMA_PREFIX, { std::to_string(user), id, bundleName }); + return GetKey(SCHEMA_PREFIX, { std::to_string(user), bundleName, std::to_string(instanceId) }); +} + +std::string CloudInfo::GetSchemaKey(const StoreMetaData &meta) +{ + return GetKey(SCHEMA_PREFIX, { meta.user, meta.bundleName, std::to_string(meta.instanceId) }); } bool CloudInfo::IsValid() const diff --git a/datamgr_service/services/distributeddataservice/framework/include/cloud/cloud_info.h b/datamgr_service/services/distributeddataservice/framework/include/cloud/cloud_info.h index d16c8cfc..dc732027 100644 --- a/datamgr_service/services/distributeddataservice/framework/include/cloud/cloud_info.h +++ b/datamgr_service/services/distributeddataservice/framework/include/cloud/cloud_info.h @@ -15,6 +15,7 @@ #ifndef OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_INFO_H #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_INFO_H +#include "metadata/store_meta_data.h" #include "serializable/serializable.h" namespace OHOS::DistributedData { class API_EXPORT CloudInfo final : public Serializable { @@ -38,7 +39,8 @@ public: std::string GetKey() const; std::map GetSchemaKey() const; - std::string GetSchemaKey(std::string bundleName) const; + std::string GetSchemaKey(const std::string &bundleName, const int32_t instanceId = 0) const; + static std::string GetSchemaKey(const StoreMetaData &meta); bool IsValid() const; bool IsExist(const std::string &bundleName) const; static std::string GetPrefix(const std::initializer_list &field); -- Gitee