diff --git a/services/dbms/src/distributed_data_storage.cpp b/services/dbms/src/distributed_data_storage.cpp index bbb411f4be28ddfd14441646755f308e6009251d..a371416ab031c60c19c26efba23f31e74ea72d87 100644 --- a/services/dbms/src/distributed_data_storage.cpp +++ b/services/dbms/src/distributed_data_storage.cpp @@ -308,7 +308,7 @@ bool DistributedDataStorage::SyncAndCompleted(const std::string &udid, const std APP_LOGE("can not get uuid by networkId error:%{public}d", ret); return false; } - if (udid.size() == 0) { + if (uuid.size() == 0) { APP_LOGE("get uuid is Empty"); return false; } @@ -481,7 +481,7 @@ std::map DistributedDataStorage::GetAllOldDi APP_LOGE("GetLocalUdid failed"); return oldDistributedBundleInfos; } - Key allEntryKeyPrefix(""); + Key allEntryKeyPrefix(udid); std::vector allEntries; Status status = kvStorePtr_->GetEntries(allEntryKeyPrefix, allEntries); if (status != Status::SUCCESS) { @@ -490,9 +490,6 @@ std::map DistributedDataStorage::GetAllOldDi } for (const auto &entry : allEntries) { std::string key = entry.key.ToString(); - if (key.find(udid) == std::string::npos) { - continue; - } std::string value = entry.value.ToString(); DistributedBundleInfo distributedBundleInfo; if (distributedBundleInfo.FromJsonString(value)) { diff --git a/services/dbms/src/image_compress.cpp b/services/dbms/src/image_compress.cpp index 894bc16b6454f3f3103b60e427fc94c33994efe0..6365e817bd2303b854828d89f1a7d2beb232fee4 100644 --- a/services/dbms/src/image_compress.cpp +++ b/services/dbms/src/image_compress.cpp @@ -151,12 +151,16 @@ bool ImageCompress::CompressImageByContent(const std::unique_ptr &fil Media::SourceOptions options; std::unique_ptr imageSourcePtr = Media::ImageSource::CreateImageSource(fileData.get(), fileSize, options, errorCode); + if (imageSourcePtr == nullptr) { + APP_LOGE("imageSourcePtr nullptr"); + return false; + } // do compress Media::DecodeOptions decodeOptions; uint32_t pixMapError = 0; std::unique_ptr pixMap = imageSourcePtr->CreatePixelMap(decodeOptions, pixMapError); if (pixMap == nullptr || pixMapError != Media::SUCCESS) { - APP_LOGE("CreatePixelMap failed!"); + APP_LOGE("CreatePixelMap failed"); return false; } double ratio = CalculateRatio(fileSize, imageType); diff --git a/services/dbms/test/unittest/distributed_bms_host_test/BUILD.gn b/services/dbms/test/unittest/distributed_bms_host_test/BUILD.gn index b11a5013c40401e949671fbd12e695154b22859b..8ae72e9d965b608e111b4aa8a2b95be5d475e13b 100644 --- a/services/dbms/test/unittest/distributed_bms_host_test/BUILD.gn +++ b/services/dbms/test/unittest/distributed_bms_host_test/BUILD.gn @@ -31,11 +31,7 @@ ohos_unittest("DistributedBmsHostTest") { "mock_distributed_bms_interface.cpp", ] - deps = [ - "${dbms_inner_api_path}:dbms_fwk", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] + deps = [ "${dbms_inner_api_path}:dbms_fwk" ] external_deps = [ "ability_base:want", @@ -47,6 +43,8 @@ ohos_unittest("DistributedBmsHostTest") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "device_manager:devicemanagersdk", + "googletest:gmock_main", + "googletest:gtest_main", "hicollie:libhicollie", "hilog:libhilog", "i18n:intl_util",