diff --git a/datamgr_service/services/distributeddataservice/framework/cloud/cloud_info.cpp b/datamgr_service/services/distributeddataservice/framework/cloud/cloud_info.cpp index d3560bb8ab6013bed3b792897c90189ef7d41c38..2f44ff853f07e4d15abea456d8bb6019f13d7e4d 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 d16c8cfce25f1f9d16cd84b2a9d8bf0a2ff44c04..dc73202775809e0f82e98ecacabfc0f8900f43f8 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);