From 94470b99b404e9d7c89b769cdc70cdee786275ed Mon Sep 17 00:00:00 2001 From: chensihan Date: Wed, 22 Jan 2025 14:26:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=B4=E6=B5=8B=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chensihan --- .../kits/js/backup/session_backup_n_exporter.cpp | 15 +++++++-------- .../session_incremental_backup_n_exporter.cpp | 15 +++++++-------- .../kits/js/backup/session_restore_n_exporter.cpp | 15 +++++++-------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/interfaces/kits/js/backup/session_backup_n_exporter.cpp b/interfaces/kits/js/backup/session_backup_n_exporter.cpp index 7f8e99ccd..3f8328333 100644 --- a/interfaces/kits/js/backup/session_backup_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_backup_n_exporter.cpp @@ -39,10 +39,6 @@ struct BackupEntity { static void OnFileReady(weak_ptr pCallbacks, const BFileInfo &fileInfo, UniqueFd fd, int sysErrno) { - if (pCallbacks.expired()) { - HILOGI("callbacks is unbound"); - return; - } auto callbacks = pCallbacks.lock(); if (!callbacks) { HILOGI("callback function onFileReady has already been released"); @@ -53,15 +49,16 @@ static void OnFileReady(weak_ptr pCallbacks, const BFileInfo & return; } ErrCode errCode = BError::GetCodeByErrno(sysErrno); - std::string errMsg = "system errno: " + to_string(sysErrno); - std::tuple errInfo = std::make_tuple(errCode, errMsg); - + std::tuple errInfo = std::make_tuple(errCode, "system errno: " + to_string(sysErrno)); + HILOGI("callback function backup onFileReady begin errCode: %{public}d, bundle: %{public}s, file: %{public}s", + std::get<0>(errInfo), fileInfo.owner.c_str(), GetAnonyPath(fileInfo.fileName).c_str()); auto cbCompl = [bundleName {fileInfo.owner}, fileName {fileInfo.fileName}, fd {make_shared(fd.Release())}, errInfo](napi_env env, NError err) -> NVal { if (err) { return {env, err.GetNapiErr(env)}; } - HILOGI("callback function backup onFileReady cbCompl errcode: %{public}d", std::get<0>(errInfo)); + HILOGI("callback function backup onFileReady errCode: %{public}d, bundle: %{public}s, file: %{public}s", + std::get<0>(errInfo), bundleName.c_str(), GetAnonyPath(fileName).c_str()); NVal obj; ErrParam errorParam = [ errInfo ]() { return errInfo; @@ -82,6 +79,8 @@ static void OnFileReady(weak_ptr pCallbacks, const BFileInfo & NVal::DeclareNapiProperty(BConstants::URI.c_str(), NVal::CreateUTF8String(env, fileName).val_), NVal::DeclareNapiProperty(BConstants::FD.c_str(), NVal::CreateInt32(env, fd->Release()).val_)}); } + HILOGI("callback function backup onFileReady end errCode: %{public}d, bundle: %{public}s, file: %{public}s", + std::get<0>(errInfo), bundleName.c_str(), GetAnonyPath(fileName).c_str()); return {obj}; }; diff --git a/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp b/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp index 2596a6e6c..4c28545ff 100644 --- a/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp @@ -42,10 +42,6 @@ struct BackupEntity { static void OnFileReady(weak_ptr pCallbacks, const BFileInfo &fileInfo, UniqueFd fd, UniqueFd manifestFd, int sysErrno) { - if (pCallbacks.expired()) { - HILOGI("callbacks is unbound"); - return; - } auto callbacks = pCallbacks.lock(); if (!callbacks) { HILOGI("callback function onFileReady has already been released"); @@ -56,9 +52,9 @@ static void OnFileReady(weak_ptr pCallbacks, const BFileInfo & return; } ErrCode errCode = BError::GetCodeByErrno(sysErrno); - std::string errMsg = "system errno: " + to_string(sysErrno); - std::tuple errInfo = std::make_tuple(errCode, errMsg); - + std::tuple errInfo = std::make_tuple(errCode, "system errno: " + to_string(sysErrno)); + HILOGI("callback function incre backup onFileReady begin errCode: %{public}d, bundle: %{public}s, file: %{public}s", + std::get<0>(errInfo), fileInfo.owner.c_str(), GetAnonyPath(fileInfo.fileName).c_str()); auto cbCompl = [bundleName {fileInfo.owner}, fileName {fileInfo.fileName}, fd {make_shared(fd.Release())}, manifestFd {make_shared(manifestFd.Release())}, @@ -66,7 +62,8 @@ static void OnFileReady(weak_ptr pCallbacks, const BFileInfo & if (err) { return {env, err.GetNapiErr(env)}; } - HILOGI("callback function incremental backup onFileReady cbCompl errcode: %{public}d", std::get<0>(errInfo)); + HILOGI("callback function incre backup onFileReady errCode: %{public}d, bundle: %{public}s, file: %{public}s", + std::get<0>(errInfo), bundleName.c_str(), GetAnonyPath(fileName).c_str()); NVal obj; ErrParam errorParam = [ errInfo ]() { return errInfo; @@ -88,6 +85,8 @@ static void OnFileReady(weak_ptr pCallbacks, const BFileInfo & NVal::DeclareNapiProperty(BConstants::MANIFEST_FD.c_str(), NVal::CreateInt32(env, manifestFd->Release()).val_)}); } + HILOGI("callback function incre backup onFileReady end errCode:%{public}d, bundle:%{public}s, file:%{public}s", + std::get<0>(errInfo), bundleName.c_str(), GetAnonyPath(fileName).c_str()); return {obj}; }; diff --git a/interfaces/kits/js/backup/session_restore_n_exporter.cpp b/interfaces/kits/js/backup/session_restore_n_exporter.cpp index 0d31df98a..201d508c0 100644 --- a/interfaces/kits/js/backup/session_restore_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_restore_n_exporter.cpp @@ -44,10 +44,6 @@ struct RestoreEntity { static void OnFileReadySheet(weak_ptr pCallbacks, const BFileInfo &fileInfo, UniqueFd fd, UniqueFd manifestFd, int32_t sysErrno) { - if (pCallbacks.expired()) { - HILOGI("callbacks is unbound"); - return; - } auto callbacks = pCallbacks.lock(); if (!callbacks) { HILOGI("callback function onFileReady has already been released"); @@ -58,9 +54,9 @@ static void OnFileReadySheet(weak_ptr pCallbacks, const BFileI return; } ErrCode errCode = BError::GetCodeByErrno(sysErrno); - std::string errMsg = "system errno: " + to_string(sysErrno); - std::tuple errInfo = std::make_tuple(errCode, errMsg); - + std::tuple errInfo = std::make_tuple(errCode, "system errno: " + to_string(sysErrno)); + HILOGI("callback function restore onFileReadySheet begin errCode: %{public}d, bundle: %{public}s, file: %{public}s", + std::get<0>(errInfo), fileInfo.owner.c_str(), GetAnonyPath(fileInfo.fileName).c_str()); auto cbCompl = [bundleName {fileInfo.owner}, fileName {fileInfo.fileName}, fd {make_shared(fd.Release())}, manifestFd {make_shared(manifestFd.Release())}, @@ -68,7 +64,8 @@ static void OnFileReadySheet(weak_ptr pCallbacks, const BFileI if (err) { return {env, err.GetNapiErr(env)}; } - HILOGI("callback function restore OnFileReadySheet errCode: %{public}d", std::get<0>(errInfo)); + HILOGI("callback function restore OnFileReadySheet errCode: %{public}d, bundle: %{public}s, file: %{public}s", + std::get<0>(errInfo), bundleName.c_str(), GetAnonyPath(fileName).c_str()); NVal obj; ErrParam errorParam = [ errInfo ]() { return errInfo; @@ -90,6 +87,8 @@ static void OnFileReadySheet(weak_ptr pCallbacks, const BFileI NVal::DeclareNapiProperty(BConstants::MANIFEST_FD.c_str(), NVal::CreateInt32(env, manifestFd->Release()).val_)}); } + HILOGI("callback function restore onFileReadySheet end errCode:%{public}d, bundle:%{public}s, file:%{public}s", + std::get<0>(errInfo), bundleName.c_str(), GetAnonyPath(fileName).c_str()); return {obj}; }; -- Gitee