From cedfa9730adf11c8f8ad82ca7d8e4e873b9777a9 Mon Sep 17 00:00:00 2001 From: fengjq Date: Sat, 13 Sep 2025 14:53:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9C=E6=B9=96=E4=BA=92=E9=80=9A6.0?= =?UTF-8?q?=E7=AB=AF=E4=BA=91=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengjq --- .../src/cloud_sync_common.cpp | 76 ++++++++++++++++--- .../cloudsync_kit_inner/cloud_sync_common.h | 18 +++-- services/cloudfiledaemon.cfg | 2 +- .../src/ipc/cloud_sync_service.cpp | 5 +- services/distributedfile.cfg | 2 +- .../cloudsync_impl/cloud_sync_common_test.cpp | 1 + 6 files changed, 83 insertions(+), 21 deletions(-) diff --git a/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp b/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp index 275ec97f5..8e97eafa8 100644 --- a/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp +++ b/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp @@ -642,23 +642,75 @@ AssetInfoObj *AssetInfoObj::Unmarshalling(Parcel &parcel) bool CleanFileInfoObj::ReadFromParcel(Parcel &parcel) { - parcel.ReadString(cloudId); - parcel.ReadInt64(size); - parcel.ReadInt64(modifiedTime); - parcel.ReadString(path); - parcel.ReadString(fileName); - parcel.ReadStringVector(&attachment); + if (!parcel.ReadInt64(size)) { + LOGE("failed to read size"); + return false; + } + if (!parcel.ReadInt64(modifiedTime)) { + LOGE("failed to read modifiedTime"); + return false; + } + if (!parcel.ReadInt32(fileSourceType)) { + LOGE("failed to read fileSourceType"); + return false; + } + if (!parcel.ReadString(cloudId)) { + LOGE("failed to read cloudId"); + return false; + } + if (!parcel.ReadString(path)) { + LOGE("failed to read path"); + return false; + } + if (!parcel.ReadString(fileName)) { + LOGE("failed to read fileName"); + return false; + } + if (!parcel.ReadString(storagePath)) { + LOGE("failed to read storagePath"); + return false; + } + if (!parcel.ReadStringVector(&attachment)) { + LOGE("failed to read attachment"); + return false; + } return true; } bool CleanFileInfoObj::Marshalling(Parcel &parcel) const { - parcel.WriteString(cloudId); - parcel.WriteInt64(size); - parcel.WriteInt64(modifiedTime); - parcel.WriteString(path); - parcel.WriteString(fileName); - parcel.WriteStringVector(attachment); + if (!parcel.WriteInt64(size)) { + LOGE("failed to write size"); + return false; + } + if (!parcel.WriteInt64(modifiedTime)) { + LOGE("failed to write modifiedTime"); + return false; + } + if (!parcel.WriteInt32(fileSourceType)) { + LOGE("failed to write fileSourceType"); + return false; + } + if (!parcel.WriteString(cloudId)) { + LOGE("failed to write cloudId"); + return false; + } + if (!parcel.WriteString(path)) { + LOGE("failed to write path"); + return false; + } + if (!parcel.WriteString(fileName)) { + LOGE("failed to write fileName"); + return false; + } + if (!parcel.WriteString(storagePath)) { + LOGE("failed to write storagePath"); + return false; + } + if (!parcel.WriteStringVector(attachment)) { + LOGE("failed to write attachment"); + return false; + } return true; } diff --git a/interfaces/inner_api/native/cloudsync_kit_inner/cloud_sync_common.h b/interfaces/inner_api/native/cloudsync_kit_inner/cloud_sync_common.h index 508b18c67..5db0ae49f 100644 --- a/interfaces/inner_api/native/cloudsync_kit_inner/cloud_sync_common.h +++ b/interfaces/inner_api/native/cloudsync_kit_inner/cloud_sync_common.h @@ -176,20 +176,24 @@ struct AssetInfoObj : public Parcelable { }; struct CleanFileInfo { + int64_t size{0}; + int64_t modifiedTime{0}; + int32_t fileSourceType{0}; std::string cloudId; - int64_t size; - int64_t modifiedTime; std::string path; std::string fileName; + std::string storagePath; std::vector attachment; }; struct CleanFileInfoObj : public Parcelable { + int64_t size{0}; + int64_t modifiedTime{0}; + int32_t fileSourceType{0}; std::string cloudId; - int64_t size; - int64_t modifiedTime; std::string path; std::string fileName; + std::string storagePath; std::vector attachment; bool ReadFromParcel(Parcel &parcel); bool Marshalling(Parcel &parcel) const override; @@ -197,11 +201,13 @@ struct CleanFileInfoObj : public Parcelable { CleanFileInfoObj() = default; CleanFileInfoObj(const CleanFileInfo &FileInfo) - : cloudId(FileInfo.cloudId), - size(FileInfo.size), + : size(FileInfo.size), modifiedTime(FileInfo.modifiedTime), + fileSourceType(FileInfo.fileSourceType), + cloudId(FileInfo.cloudId), path(FileInfo.path), fileName(FileInfo.fileName), + storagePath(FileInfo.storagePath) attachment(FileInfo.attachment) { } diff --git a/services/cloudfiledaemon.cfg b/services/cloudfiledaemon.cfg index 036a50c65..cc60ee4c7 100644 --- a/services/cloudfiledaemon.cfg +++ b/services/cloudfiledaemon.cfg @@ -3,7 +3,7 @@ "name": "cloudfiledaemon", "path": ["/system/bin/sa_main", "/system/profile/cloudfiledaemon.json"], "uid": "1009", - "gid": ["dfs", "user_data_rw", "ddms", "dfs_share", "readproc"], + "gid": ["dfs", "user_data_rw", "ddms", "dfs_share", "media_rw", "readproc"], "caps": ["CHOWN"], "sandbox": 0, "secon": "u:r:cloudfiledaemon:s0", diff --git a/services/cloudsyncservice/src/ipc/cloud_sync_service.cpp b/services/cloudsyncservice/src/ipc/cloud_sync_service.cpp index e69e67368..11161184c 100644 --- a/services/cloudsyncservice/src/ipc/cloud_sync_service.cpp +++ b/services/cloudsyncservice/src/ipc/cloud_sync_service.cpp @@ -1078,7 +1078,10 @@ int32_t CloudSyncService::BatchCleanFile(const std::vector &fi std::vector cleanFilesInfo; for (const auto &obj : fileInfo) { - CleanFileInfo tmpFileInfo{obj.cloudId, obj.size, obj.modifiedTime, obj.path, obj.fileName, obj.attachment}; + CleanFileInfo tmpFileInfo{ + obj.size, obj.modifiedTime, obj.fileSourceType, obj.cloudId, obj.path, obj.fileName, + obj.storagePath, obj.attachment, + }; cleanFilesInfo.emplace_back(tmpFileInfo); } diff --git a/services/distributedfile.cfg b/services/distributedfile.cfg index e59489ab8..11fe2c37e 100644 --- a/services/distributedfile.cfg +++ b/services/distributedfile.cfg @@ -37,7 +37,7 @@ "name": "cloudfileservice", "path": ["/system/bin/sa_main", "/system/profile/cloudfileservice.json"], "uid": "dfs", - "gid": ["dfs", "user_data_rw", "ddms", "dfs_share"], + "gid": ["dfs", "user_data_rw", "ddms", "dfs_share", "media_rw"], "caps": ["CHOWN"], "sandbox": 0, "jobs" : { diff --git a/test/unittests/cloudsync_api/cloudsync_impl/cloud_sync_common_test.cpp b/test/unittests/cloudsync_api/cloudsync_impl/cloud_sync_common_test.cpp index 021186557..e1479ae2e 100644 --- a/test/unittests/cloudsync_api/cloudsync_impl/cloud_sync_common_test.cpp +++ b/test/unittests/cloudsync_api/cloudsync_impl/cloud_sync_common_test.cpp @@ -1089,6 +1089,7 @@ HWTEST_F(CloudSyncCommonTest, UnmarshallingTest2, TestSize.Level1) { GTEST_LOG_(INFO) << "UnmarshallingTest2 Start"; try { + // ToDo: 待修改 auto Info = make_shared(); Parcel parcel; bool returnValues[3] = {true, true, true}; -- Gitee