From bdc2c3cc90fdefec7f5ff4f2f5b7bdd4d2386573 Mon Sep 17 00:00:00 2001 From: liuhonglin9 Date: Wed, 22 Nov 2023 01:17:00 +0000 Subject: [PATCH] gaojing Signed-off-by: liuhonglin9 Change-Id: I3ed17381fc7f2ea928cbdd172a5fe0aad7fddcf7 --- .../src/js_file_access_ext_ability.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp b/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp index d399f10a..68579e52 100644 --- a/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp +++ b/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp @@ -240,19 +240,18 @@ int JsFileAccessExtAbility::CallJsMethod(const std::string &funcName, JsRuntime loop, work.get(), [](uv_work_t *work) {}, [](uv_work_t *work, int status) { CallJsParam *param = reinterpret_cast(work->data); - if (param == nullptr) { - HILOG_ERROR("failed to get CallJsParam."); - return; - } - napi_handle_scope scope = nullptr; napi_env env = reinterpret_cast(&(param->jsRuntime->GetNativeEngine())); napi_open_handle_scope(env, &scope); - - if (DoCallJsMethod(param) != ERR_OK) { - HILOG_ERROR("failed to call DoCallJsMethod."); - } - + do { + if (param == nullptr) { + HILOG_ERROR("failed to get CallJsParam."); + break; + } + if (DoCallJsMethod(param) != ERR_OK) { + HILOG_ERROR("failed to call DoCallJsMethod."); + } + } while (false); std::unique_lock lock(param->fileOperateMutex); param->isReady = true; param->fileOperateCondition.notify_one(); -- Gitee