From 2551099baf039552954e961dd38f3390b8a7000f Mon Sep 17 00:00:00 2001 From: zhangkaixiang Date: Thu, 23 Feb 2023 16:20:32 +0800 Subject: [PATCH] return the uri when file is exist Signed-off-by: zhangkaixiang --- .../src/remote_file_share.cpp | 20 +++++++++++-------- 1 file changed, 12 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..05be3c14d 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,18 @@ 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