From 242fb54af207a3a0d09111643ff1f36923e8ea73 Mon Sep 17 00:00:00 2001 From: zhangkaixiang Date: Thu, 16 Feb 2023 15:17:47 +0800 Subject: [PATCH] return the uri when file is exist Signed-off-by: zhangkaixiang --- .../src/remote_file_share.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/services/remote_file_share/src/remote_file_share.cpp b/services/remote_file_share/src/remote_file_share.cpp index c994779fb..0252549bf 100644 --- a/services/remote_file_share/src/remote_file_share.cpp +++ b/services/remote_file_share/src/remote_file_share.cpp @@ -197,14 +197,6 @@ int RemoteFileShare::CreateSharePath(const int &fd, std::string &sharePath, return errno; } - if (CreateShareFile(shareControl, realPath, deviceId) != 0) { - LOGE("RemoteFileShare::CreateSharePath, create share file failed with %{public}d", errno); - /* When the file is exist, we should not delete the dictionary */ - if (errno != EEXIST) - DeleteShareDir(PACKAGE_PATH, LOWER_SHARE_PATH); - return errno; - } - std::string file_name = GetFileName(shareControl.fd); if (file_name == "") { LOGE("RemoteFileShare::CreateSharePath, get error file name"); @@ -212,6 +204,17 @@ int RemoteFileShare::CreateSharePath(const int &fd, std::string &sharePath, return EBADF; } sharePath = SHARE_PATH + "/" + file_name; + + if (CreateShareFile(shareControl, realPath, deviceId) != 0) { + LOGE("RemoteFileShare::CreateSharePath, create share file failed with %{public}d", errno); + /* When the file is exist, we should not delete the dictionary */ + if (errno == EEXIST) { + return 0; + } + sharePath = ""; + DeleteShareDir(PACKAGE_PATH, LOWER_SHARE_PATH); + return errno; + } LOGI("RemoteFileShare::CreateSharePath, create %{public}s successfully", sharePath.c_str()); return 0; } -- Gitee