diff --git a/tools/backup_tool/src/tools_op_restore.cpp b/tools/backup_tool/src/tools_op_restore.cpp index f978d3a429e1c29e328d108c47fbdc23ff9cc169..c5259997fe295ea355032b38da41f1279e407358 100644 --- a/tools/backup_tool/src/tools_op_restore.cpp +++ b/tools/backup_tool/src/tools_op_restore.cpp @@ -239,7 +239,12 @@ static bool GetRealPath(string &path) if (realpath(path.c_str(), absPath.get()) == nullptr) { return false; } + path = absPath.get(); + if (access(path.data(), F_OK) != 0) { + return false; + } + return true; } @@ -252,10 +257,6 @@ static int32_t InitPathCapFile(const string &pathCapFile, vector bundleN return -errno; } - if (access(realPath.data(), F_OK) != 0) { - return -errno; - } - UniqueFd fd(open(realPath.data(), O_RDWR, S_IRWXU)); if (fd < 0) { fprintf(stderr, "Failed to open file error: %d %s\n", errno, strerror(errno));