diff --git a/interfaces/common/src/sandbox_helper.cpp b/interfaces/common/src/sandbox_helper.cpp index fb70c5dec6f5a8262f8037582d438e3cdc23e31e..140fb61e92a30718a408d1c3b09846d0417a2742 100644 --- a/interfaces/common/src/sandbox_helper.cpp +++ b/interfaces/common/src/sandbox_helper.cpp @@ -280,12 +280,11 @@ int32_t SandboxHelper::GetPhysicalPath(const std::string &fileUri, const std::st { Uri uri(fileUri); string bundleName = uri.GetAuthority(); - string sandboxPath = SandboxHelper::Decode(uri.GetPath()); - if (bundleName == MEDIA) { - return GetMediaPhysicalPath(sandboxPath, userId, physicalPath); + return GetMediaPhysicalPath(uri.GetPath(), userId, physicalPath); } + string sandboxPath = SandboxHelper::Decode(uri.GetPath()); if ((sandboxPath.find(FILE_MANAGER_URI_HEAD) == 0 && bundleName != FILE_MANAGER_AUTHORITY) || (sandboxPath.find(FUSE_URI_HEAD) == 0 && bundleName != DLP_MANAGER_BUNDLE_NAME)) { return -EINVAL; diff --git a/test/unittest/file_share_native/file_share_test.cpp b/test/unittest/file_share_native/file_share_test.cpp index 0af2942fbd4c54dc67fe3617ed170f5323200c62..b57eb4ba50e90aafd735c5b855fb8a84714fa0d7 100644 --- a/test/unittest/file_share_native/file_share_test.cpp +++ b/test/unittest/file_share_native/file_share_test.cpp @@ -389,11 +389,18 @@ HWTEST_F(FileShareTest, File_share_GetPhysicalPath_0004, testing::ext::TestSize. HWTEST_F(FileShareTest, File_share_GetPhysicalPath_0005, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_GetPhysicalPath_0005"; - std::string fileUri = "file://media/Photo/12/IMG_12345_999999/test.jpg"; + std::string strPrefix = "file://media/"; + std::string fileUri = "Photo/12/IMG_12345_999999/test.jpg"; std::string physicalPath; - int32_t ret = SandboxHelper::GetPhysicalPath(fileUri, "100", physicalPath); + int32_t ret = SandboxHelper::GetPhysicalPath(strPrefix + SandboxHelper::Encode(fileUri), "100", physicalPath); EXPECT_EQ(ret, E_OK); EXPECT_EQ(physicalPath, "/mnt/hmdfs/100/account/cloud_merge_view/files/Photo/575/IMG_12345_999999.jpg"); + + std::string fileUri2 = "Photo/12/IMG_12345_999999/test .jpg"; + std::string physicalPath2; + ret = SandboxHelper::GetPhysicalPath(strPrefix + SandboxHelper::Encode(fileUri2), "100", physicalPath2); + EXPECT_EQ(ret, E_OK); + EXPECT_EQ(physicalPath2, "/mnt/hmdfs/100/account/cloud_merge_view/files/Photo/575/IMG_12345_999999.jpg"); GTEST_LOG_(INFO) << "FileShareTest-end File_share_GetPhysicalPath_0005"; }