diff --git a/frameworks/innerkitsimpl/media_library_cloud_sync/include/cloud_media_album_handler.h b/frameworks/innerkitsimpl/media_library_cloud_sync/include/cloud_media_album_handler.h index cd4f4e5304c6552cdea0cc888f6a3bd7f27ab195..5657cf8fcb147c919b15751459aa822d60c0e73d 100644 --- a/frameworks/innerkitsimpl/media_library_cloud_sync/include/cloud_media_album_handler.h +++ b/frameworks/innerkitsimpl/media_library_cloud_sync/include/cloud_media_album_handler.h @@ -60,7 +60,7 @@ public: int32_t GetRetryRecords(std::vector &records) override; int32_t OnStartSync() override; int32_t OnCompleteSync() override; - int32_t OnCompletePull() override; + int32_t OnCompletePull(const MediaOperateResult &optRet = {"", 0, ""}) override; int32_t OnCompletePush() override; int32_t OnCompleteCheck() override; diff --git a/frameworks/innerkitsimpl/media_library_cloud_sync/include/cloud_media_photo_handler.h b/frameworks/innerkitsimpl/media_library_cloud_sync/include/cloud_media_photo_handler.h index 6b487b7d4988a01ec7d5692117b4f2cdf2cc7aaf..69d467cf1bba13ac77dc2afe51639b4a63a33545 100644 --- a/frameworks/innerkitsimpl/media_library_cloud_sync/include/cloud_media_photo_handler.h +++ b/frameworks/innerkitsimpl/media_library_cloud_sync/include/cloud_media_photo_handler.h @@ -61,7 +61,7 @@ public: int32_t GetRetryRecords(std::vector &records) override; int32_t OnStartSync() override; int32_t OnCompleteSync() override; - int32_t OnCompletePull() override; + int32_t OnCompletePull(const MediaOperateResult &optRet = {"", 0, ""}) override; int32_t OnCompletePush() override; int32_t OnCompleteCheck() override; diff --git a/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_album_handler.cpp b/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_album_handler.cpp index f94b90aea44c8988c0b16807a1441fa3ef8cdd15..da052a988276cbf8e0536a259c7b4bb61cb5e61c 100644 --- a/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_album_handler.cpp +++ b/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_album_handler.cpp @@ -34,6 +34,7 @@ #include "cloud_album_data_convert.h" #include "get_check_records_album_vo.h" #include "failed_size_resp_vo.h" +#include "media_operate_result_vo.h" namespace OHOS::Media::CloudSync { void CloudMediaAlbumHandler::SetUserId(const int32_t &userId) @@ -376,13 +377,17 @@ int32_t CloudMediaAlbumHandler::OnCompleteSync() .Post(operationCode); } -int32_t CloudMediaAlbumHandler::OnCompletePull() +int32_t CloudMediaAlbumHandler::OnCompletePull(const MediaOperateResult &optRet) { MEDIA_INFO_LOG("OnCompletePull enter"); + MediaOperateResultRespBodyResultNode reqBody; + reqBody.cloudId = optRet.cloudId; + reqBody.errorCode = optRet.errorCode; + reqBody.errorMsg = optRet.errorMsg; uint32_t operationCode = static_cast(CloudMediaAlbumOperationCode::CMD_ON_COMPLETE_PULL); return IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_) .SetHeader({{PhotoColumn::CLOUD_TYPE, to_string(cloudType_)}}) - .Post(operationCode); + .Post(operationCode, reqBody); } int32_t CloudMediaAlbumHandler::OnCompletePush() diff --git a/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_data_handler.cpp b/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_data_handler.cpp index d9de3e386c20c77ff9e362f89e66a3fdfb01c679..e1f480d776fff61882cee2f1a3e0d77bb06213c2 100644 --- a/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_data_handler.cpp +++ b/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_data_handler.cpp @@ -256,7 +256,7 @@ int32_t CloudMediaDataHandler::OnCompleteSync() return this->dataHandler_->OnCompleteSync(); } -int32_t CloudMediaDataHandler::OnCompletePull() +int32_t CloudMediaDataHandler::OnCompletePull(const MediaOperateResult &optRet) { if (this->dataHandler_ == nullptr) { MEDIA_ERR_LOG("No data handler found! tableName: %{public}s", this->tableName_.c_str()); diff --git a/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_photo_handler.cpp b/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_photo_handler.cpp index 1a6538e07248c0d48ae593261f9c758d2d3e736c..1bfcbcab05bcbb6e6e0cb8be8082f79c91d6be7b 100644 --- a/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_photo_handler.cpp +++ b/frameworks/innerkitsimpl/media_library_cloud_sync/src/cloud_media_photo_handler.cpp @@ -535,7 +535,7 @@ int32_t CloudMediaPhotoHandler::OnCompleteSync() .Post(operationCode); } -int32_t CloudMediaPhotoHandler::OnCompletePull() +int32_t CloudMediaPhotoHandler::OnCompletePull(const MediaOperateResult &optRet) { MEDIA_INFO_LOG("OnCompletePull enter"); uint32_t operationCode = static_cast(CloudMediaPhotoOperationCode::CMD_ON_COMPLETE_PULL); diff --git a/frameworks/innerkitsimpl/test/unittest/media_library_cloud_sync_service_test/src/media_cloud_sync_service_service_test.cpp b/frameworks/innerkitsimpl/test/unittest/media_library_cloud_sync_service_test/src/media_cloud_sync_service_service_test.cpp index 2e54f1a199dbfee29dbd9ae1feb078e170c614a9..8237025006877c2dc82eca1ea3dde94401f85970 100644 --- a/frameworks/innerkitsimpl/test/unittest/media_library_cloud_sync_service_test/src/media_cloud_sync_service_service_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/media_library_cloud_sync_service_test/src/media_cloud_sync_service_service_test.cpp @@ -1985,11 +1985,11 @@ HWTEST_F(CloudMediaSyncServiceTest, CloudMediaScanService_RemoveLocalFile_Test_0 CloudMediaPhotosService service; CloudMediaPullDataDto dto; dto.localPath = ""; - dto.attributesSubtype = static_cast(PhotoSubType::MOVING_PHOTO); - dto.attributesMovingPhotoEffectMode = 0; - dto.attributesOriginalSubtype = 0; + dto.localSubtype = static_cast(PhotoSubType::MOVING_PHOTO); + dto.localMovingPhotoEffectMode = 0; + dto.localOriginalSubtype = 0; int32_t ret = service.RemoveLocalFile(dto); - EXPECT_NE(ret, E_OK); // 暂未配置能删除的资源,先预期not ok + EXPECT_EQ(ret, E_OK); } HWTEST_F(CloudMediaSyncServiceTest, CloudMediaScanService_ClearLocalData_Test_001, TestSize.Level1) diff --git a/interfaces/inner_api/native/cloud_sync/cloud_media_data_handler.h b/interfaces/inner_api/native/cloud_sync/cloud_media_data_handler.h index 4627009745c18f97df61b06f32504180c376c79f..116473926a5971e1ba2ed84cbb424c011e64fe40 100644 --- a/interfaces/inner_api/native/cloud_sync/cloud_media_data_handler.h +++ b/interfaces/inner_api/native/cloud_sync/cloud_media_data_handler.h @@ -73,7 +73,7 @@ public: int32_t GetRetryRecords(std::vector &records) override; int32_t OnStartSync() override; int32_t OnCompleteSync() override; - int32_t OnCompletePull() override; + int32_t OnCompletePull(const MediaOperateResult &optRet = {"", 0, ""}) override; int32_t OnCompletePush() override; int32_t OnCompleteCheck() override; }; diff --git a/interfaces/inner_api/native/cloud_sync/i_cloud_media_data_handler.h b/interfaces/inner_api/native/cloud_sync/i_cloud_media_data_handler.h index b65b76cc0170da56b1ae6d36146934c89af02deb..6b941380abdb43ff8d164294905348339e8ca99c 100644 --- a/interfaces/inner_api/native/cloud_sync/i_cloud_media_data_handler.h +++ b/interfaces/inner_api/native/cloud_sync/i_cloud_media_data_handler.h @@ -24,6 +24,7 @@ #include "mdk_record.h" #include "mdk_reference.h" #include "mdk_database.h" +#include "media_operate_result.h" namespace OHOS::Media::CloudSync { #define EXPORT __attribute__ ((visibility ("default"))) @@ -54,7 +55,7 @@ public: virtual int32_t GetRetryRecords(std::vector &records) = 0; virtual int32_t OnStartSync() = 0; virtual int32_t OnCompleteSync() = 0; - virtual int32_t OnCompletePull() = 0; + virtual int32_t OnCompletePull(const MediaOperateResult &optRet = {"", 0, ""}) = 0; virtual int32_t OnCompletePush() = 0; virtual int32_t OnCompleteCheck() = 0; }; diff --git a/services/media_cloud_sync_service/include/dto/cloud_media_pull_data_dto.h b/services/media_cloud_sync_service/include/dto/cloud_media_pull_data_dto.h index 10452513b3cbe852b99251faabd7f0872586e536..679375f62f3c6c9df498654a12b44df3cbb5574e 100644 --- a/services/media_cloud_sync_service/include/dto/cloud_media_pull_data_dto.h +++ b/services/media_cloud_sync_service/include/dto/cloud_media_pull_data_dto.h @@ -108,6 +108,9 @@ public: int32_t localThumbState{-1}; std::string localOriginalAssetCloudId; int32_t localExifRotate{-1}; + int32_t localSubtype{-1}; + int32_t localMovingPhotoEffectMode{-1}; + int32_t localOriginalSubtype{-1}; public: // basic function std::string ToString() const; diff --git a/services/media_cloud_sync_service/include/service/cloud_media_album_service.h b/services/media_cloud_sync_service/include/service/cloud_media_album_service.h index 8076f6e666d39e1d9ac7aca29f75b46eb47cc297..92cf35703f2005a507b8cf49e55c983d25eaa415 100644 --- a/services/media_cloud_sync_service/include/service/cloud_media_album_service.h +++ b/services/media_cloud_sync_service/include/service/cloud_media_album_service.h @@ -28,6 +28,7 @@ #include "dataobs_mgr_changeinfo.h" #include "cloud_media_album_dao.h" #include "cloud_media_define.h" +#include "media_operate_result.h" namespace OHOS::Media::CloudSync { class EXPORT CloudMediaAlbumService { @@ -51,7 +52,7 @@ public: int32_t OnDentryFileInsert(); int32_t OnStartSync(); int32_t OnCompleteSync(); - int32_t OnCompletePull(); + int32_t OnCompletePull(const MediaOperateResult &optRet = {"", 0, ""}); int32_t OnCompletePush(); int32_t OnCompleteCheck(); void CheckAlbumManualCover(); diff --git a/services/media_cloud_sync_service/include/utils/cloud_media_sync_utils.h b/services/media_cloud_sync_service/include/utils/cloud_media_sync_utils.h index e5f2d53cef32cb218502536b05fa8cb72ebf0b50..49b1f96a0ddcfe0f86004ef2b422b317eff2371f 100644 --- a/services/media_cloud_sync_service/include/utils/cloud_media_sync_utils.h +++ b/services/media_cloud_sync_service/include/utils/cloud_media_sync_utils.h @@ -43,9 +43,8 @@ public: static void RemoveEditDataParentPath(const std::string &path, const std::string &prefixCloud); static void RemoveMetaDataPath(const std::string &path, const std::string &prefixCloud); static void InvalidVideoCache(const std::string &localPath); - static void RemoveMovingPhoto(const CloudMediaPullDataDto &pullData); - static void BackUpEditDataSourcePath(const std::string &localPath); - static void RemoveEditDataSourcePath(const std::string &localPath); + static void RemoveMovingPhoto(const std::string &localPath, const int32_t subtype, + const int32_t movingPhotoEffectMode, const int32_t originalSubtype); static void RemoveEditDataPath(const std::string &localPath); static void RemoveTransCodePath(const std::string &localPath); static uint32_t GenerateCloudIdWithHash(PhotoAlbumPo &record); @@ -65,7 +64,6 @@ public: static std::string GetSourceMovingPhotoImagePath(const std::string& photoPath); static std::string GetSourceMovingPhotoVideoPath(const std::string& photoPath); static bool IsMovingPhoto(const PhotosPo &photosPo); - static bool IsMovingPhoto(const CloudMediaPullDataDto &pullData); static bool IsGraffiti(const PhotosPo &photosPo); static bool IsLivePhoto(const PhotosPo &photosPo); static int32_t UpdateModifyTime(const std::string &localPath, int64_t localMtime); diff --git a/services/media_cloud_sync_service/src/controller/cloud_media_album_controller_service.cpp b/services/media_cloud_sync_service/src/controller/cloud_media_album_controller_service.cpp index 786a5b584c9f4c1e0d1169275645e29b3b7ffdc1..64b2271f0be37ed4517310e78395b3bd742f8908 100644 --- a/services/media_cloud_sync_service/src/controller/cloud_media_album_controller_service.cpp +++ b/services/media_cloud_sync_service/src/controller/cloud_media_album_controller_service.cpp @@ -31,6 +31,7 @@ #include "on_mdirty_records_album_vo.h" #include "get_check_records_album_vo.h" #include "failed_size_resp_vo.h" +#include "media_operate_result_vo.h" namespace OHOS::Media::CloudSync { int32_t CloudMediaAlbumControllerService::OnFetchRecords(MessageParcel &data, MessageParcel &reply) @@ -263,7 +264,18 @@ int32_t CloudMediaAlbumControllerService::OnCompleteSync(MessageParcel &data, Me int32_t CloudMediaAlbumControllerService::OnCompletePull(MessageParcel &data, MessageParcel &reply) { - int32_t ret = this->albumService_.OnCompletePull(); + MediaOperateResultRespBodyResultNode reqBody; + int32_t ret = IPC::UserDefineIPC().ReadRequestBody(data, reqBody); + if (ret != E_OK) { + MEDIA_ERR_LOG("CloudMediaAlbumControllerService::OnCompletePull Read Req Error"); + return IPC::UserDefineIPC().WriteResponseBody(reply, ret); + } + MediaOperateResult optRet; + optRet.cloudId = reqBody.cloudId; + optRet.errorCode = reqBody.errorCode; + optRet.errorMsg = reqBody.errorMsg; + MEDIA_INFO_LOG("album OnCompletePull: %{public}s", reqBody.ToString().c_str()); + ret = this->albumService_.OnCompletePull(optRet); return IPC::UserDefineIPC().WriteResponseBody(reply, ret); } diff --git a/services/media_cloud_sync_service/src/service/cloud_media_album_service.cpp b/services/media_cloud_sync_service/src/service/cloud_media_album_service.cpp index 5f3cf9aae9d2c3de5c15d277df75bce130b1634b..1274442466edbfeabc36d7381ba765cdfaa0e75a 100644 --- a/services/media_cloud_sync_service/src/service/cloud_media_album_service.cpp +++ b/services/media_cloud_sync_service/src/service/cloud_media_album_service.cpp @@ -551,8 +551,9 @@ int32_t CloudMediaAlbumService::OnCompleteSync() return 0; } -int32_t CloudMediaAlbumService::OnCompletePull() +int32_t CloudMediaAlbumService::OnCompletePull(const MediaOperateResult &optRet) { + CHECK_AND_RETURN_RET_LOG(optRet.errorCode == 0, E_OK, "OnCompletePull errCode:%{public}d", optRet.errorCode); std::vector failedAlbumIds; int32_t ret = OnDeleteAlbums(failedAlbumIds); return ret; diff --git a/services/media_cloud_sync_service/src/service/cloud_media_photos_service.cpp b/services/media_cloud_sync_service/src/service/cloud_media_photos_service.cpp index b7587fed21607443935b7fe7be73f4b03e6f8268..f940dcc47dabbdda44c786dc8265349b98f479cf 100644 --- a/services/media_cloud_sync_service/src/service/cloud_media_photos_service.cpp +++ b/services/media_cloud_sync_service/src/service/cloud_media_photos_service.cpp @@ -146,13 +146,10 @@ int32_t CloudMediaPhotosService::ClearLocalData(const CloudMediaPullDataDto &pul CloudMediaSyncUtils::RemoveThmParentPath(pullData.localPath, PhotoColumn::FILES_CLOUD_DIR); CloudMediaSyncUtils::RemoveMetaDataPath(pullData.localPath, PhotoColumn::FILES_CLOUD_DIR); CloudMediaSyncUtils::RemoveEditDataPath(pullData.localPath); - // for cloud enhancement composite photo - if (EnhancementManager::GetInstance().IsCloudEnhancementSupposed() && - PhotoFileUtils::IsEditDataSourceBackExists(pullData.localPath)) { - CloudMediaSyncUtils::BackUpEditDataSourcePath(pullData.localPath); - } - CloudMediaSyncUtils::RemoveEditDataSourcePath(pullData.localPath); - CloudMediaSyncUtils::RemoveMovingPhoto(pullData); + CloudMediaSyncUtils::RemoveMovingPhoto(pullData.localPath, + pullData.attributesSubtype, + pullData.attributesMovingPhotoEffectMode, + pullData.attributesOriginalSubtype); if (pullData.attributesMediaType == static_cast(MediaType::MEDIA_TYPE_VIDEO)) { CloudMediaSyncUtils::InvalidVideoCache(pullData.localPath); } @@ -571,9 +568,9 @@ static void SetPullDataFromPhotosPo(CloudMediaPullDataDto &pullData, const Photo pullData.dateTaken = photo.dateTaken.value_or(0); pullData.localOriginalAssetCloudId = photo.originalAssetCloudId.value_or(""); pullData.localExifRotate = photo.exifRotate.value_or(0); - pullData.attributesSubtype = photo.subtype.value_or(0); - pullData.attributesMovingPhotoEffectMode = photo.movingPhotoEffectMode.value_or(0); - pullData.attributesOriginalSubtype = photo.originalSubtype.value_or(0); + pullData.localSubtype = photo.subtype.value_or(0); + pullData.localMovingPhotoEffectMode = photo.movingPhotoEffectMode.value_or(0); + pullData.localOriginalSubtype = photo.originalSubtype.value_or(0); } int32_t CloudMediaPhotosService::OnFetchRecords(const std::vector &cloudIds, @@ -1235,8 +1232,9 @@ int32_t CloudMediaPhotosService::RemoveLocalFile(const CloudMediaPullDataDto &pu CloudMediaSyncUtils::RemoveMetaDataPath(pullData.localPath, prefixCloud); CloudMediaSyncUtils::InvalidVideoCache(pullData.localPath); CloudMediaSyncUtils::RemoveEditDataPath(pullData.localPath); - CloudMediaSyncUtils::RemoveMovingPhoto(pullData); - CloudMediaSyncUtils::RemoveTransCodePath(pullData.localPath); + // 彻底删除下行场景,下发的动图相关判断依据字段缺失,使用本地数据进行判断 + CloudMediaSyncUtils::RemoveMovingPhoto( + pullData.localPath, pullData.localSubtype, pullData.localMovingPhotoEffectMode, pullData.localOriginalSubtype); return E_OK; } } // namespace OHOS::Media::CloudSync \ No newline at end of file diff --git a/services/media_cloud_sync_service/src/utils/cloud_media_sync_utils.cpp b/services/media_cloud_sync_service/src/utils/cloud_media_sync_utils.cpp index eec6688ea14518168515fa23baa4d9d133314101..c456bf8575cccca7a0e133e739e18ff129d9317d 100644 --- a/services/media_cloud_sync_service/src/utils/cloud_media_sync_utils.cpp +++ b/services/media_cloud_sync_service/src/utils/cloud_media_sync_utils.cpp @@ -339,28 +339,20 @@ void CloudMediaSyncUtils::RemoveEditDataPath(const std::string &localPath) } } -void CloudMediaSyncUtils::RemoveTransCodePath(const std::string &localPath) -{ - std::string transCodePath = GetTransCodePath(localPath); - MEDIA_INFO_LOG("RemoveTransCodePath TransCodePath: %{public}s", transCodePath.c_str()); - if (unlink(transCodePath.c_str()) != 0 && errno != ENOENT) { - MEDIA_ERR_LOG("[CloudMedia] unlink transCode failed, errno %{public}d", errno); - } else { - MEDIA_INFO_LOG("[CloudMedia] Delete transCode file Success!"); - } -} - -void CloudMediaSyncUtils::RemoveMovingPhoto(const CloudMediaPullDataDto &pullData) -{ - CHECK_AND_RETURN_LOG(IsMovingPhoto(pullData), "RemoveMovingPhoto Is not MovingPhoto"); - MEDIA_INFO_LOG( - "RemoveMovingPhoto MovingPhotoVideoPath: %{public}s", GetMovingPhotoVideoPath(pullData.localPath).c_str()); - if (unlink(GetMovingPhotoVideoPath(pullData.localPath).c_str()) != 0 && errno != ENOENT) { +void CloudMediaSyncUtils::RemoveMovingPhoto(const std::string &localPath, const int32_t subtype, + const int32_t movingPhotoEffectMode, const int32_t originalSubtype) +{ + CHECK_AND_RETURN_LOG(MovingPhotoFileUtils::IsMovingPhoto(subtype, movingPhotoEffectMode, originalSubtype), + "RemoveMovingPhoto Is not MovingPhoto, %{public}d, %{public}d, %{public}d", + subtype, + movingPhotoEffectMode, + originalSubtype); + MEDIA_INFO_LOG("RemoveMovingPhoto MovingPhotoVideoPath: %{public}s", GetMovingPhotoVideoPath(localPath).c_str()); + if (unlink(GetMovingPhotoVideoPath(localPath).c_str()) != 0 && errno != ENOENT) { MEDIA_ERR_LOG("unlink moving photo's video failed, errno %{public}d", errno); } - MEDIA_INFO_LOG( - "RemoveMovingPhoto ExtraDataPath: %{public}s", GetMovingPhotoExtraDataPath(pullData.localPath).c_str()); - if (unlink(GetMovingPhotoExtraDataPath(pullData.localPath).c_str()) != 0 && errno != ENOENT) { + MEDIA_INFO_LOG("RemoveMovingPhoto ExtraDataPath: %{public}s", GetMovingPhotoExtraDataPath(localPath).c_str()); + if (unlink(GetMovingPhotoExtraDataPath(localPath).c_str()) != 0 && errno != ENOENT) { MEDIA_ERR_LOG("unlink moving photo's video failed, errno %{public}d", errno); } } @@ -464,14 +456,6 @@ bool CloudMediaSyncUtils::IsMovingPhoto(const PhotosPo &photosPo) return MovingPhotoFileUtils::IsMovingPhoto(subtype, movingPhotoEffectMode, originalSubtype); } -bool CloudMediaSyncUtils::IsMovingPhoto(const CloudMediaPullDataDto &pullData) -{ - int32_t subtype = pullData.attributesSubtype; - int32_t movingPhotoEffectMode = pullData.attributesMovingPhotoEffectMode; - int32_t originalSubtype = pullData.attributesOriginalSubtype; - return MovingPhotoFileUtils::IsMovingPhoto(subtype, movingPhotoEffectMode, originalSubtype); -} - bool CloudMediaSyncUtils::IsGraffiti(const PhotosPo &photosPo) { int32_t subtype = photosPo.subtype.value_or(0);