diff --git a/interfaces/kits/js/src/mod_fs/properties/close.cpp b/interfaces/kits/js/src/mod_fs/properties/close.cpp index 05cf915c461b64a36d79f7079cf8e16d91cd6d2c..76b639afe10b73f5bd3e418fa2347ac03beda858 100755 --- a/interfaces/kits/js/src/mod_fs/properties/close.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/close.cpp @@ -98,6 +98,11 @@ napi_value Close::Sync(napi_env env, napi_callback_info info) return nullptr; } } else { + auto err = CloseFd(fileStruct.fileEntity->fd_->GetFD()); + if (err) { + err.ThrowErr(env); + return nullptr; + } auto fp = NClass::RemoveEntityOfFinal(env, funcArg[NARG_POS::FIRST]); if (!fp) { NError(EINVAL).ThrowErr(env); @@ -125,6 +130,8 @@ napi_value Close::Async(napi_env env, napi_callback_info info) } if (!fileStruct.isFd) { + fileStruct.fd = fileStruct.fileEntity->fd_->GetFD(); + fileStruct.isFd = true; auto fp = NClass::RemoveEntityOfFinal(env, funcArg[NARG_POS::FIRST]); if (!fp) { NError(EINVAL).ThrowErr(env); diff --git a/interfaces/kits/js/src/mod_fs/properties/open.cpp b/interfaces/kits/js/src/mod_fs/properties/open.cpp index 822e9eaf67f5101bec4e1a804a74c0e884bea7c6..988280f81a86619fb7ffbf9b614e3f5fcdf585c0 100644 --- a/interfaces/kits/js/src/mod_fs/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/open.cpp @@ -81,7 +81,7 @@ static NVal InstantiateFile(napi_env env, int fd, string pathOrUri, bool isUri) } return NVal(); } - auto fdg = make_unique(fd, true); + auto fdg = make_unique(fd, false); fileEntity->fd_.swap(fdg); if (isUri) { fileEntity->path_ = "";