From 3c40fa27823e70215261d3845275360f85e59623 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 5 Jan 2024 16:11:24 +0800 Subject: fix: slove some known issues --- src/core/function/gpg/GpgCommandExecutor.cpp | 52 ++++++++++++---------------- 1 file changed, 23 insertions(+), 29 deletions(-) (limited to 'src/core/function/gpg/GpgCommandExecutor.cpp') diff --git a/src/core/function/gpg/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp index 6718d62a..fbcb1e4d 100644 --- a/src/core/function/gpg/GpgCommandExecutor.cpp +++ b/src/core/function/gpg/GpgCommandExecutor.cpp @@ -54,29 +54,27 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context) SPDLOG_DEBUG("building task: called cmd {} arguments size: {}", cmd, arguments.size()); - Thread::Task::TaskCallback result_callback = - [cmd, joined_argument](int /*rtn*/, const DataObjectPtr &data_object) { - SPDLOG_DEBUG( - "data object args count of cmd executor result callback: {}", - data_object->GetObjectSize()); - if (!data_object->Check()) { - throw std::runtime_error("invalid data object size"); - } - - auto exit_code = ExtractParams(data_object, 0); - auto process_stdout = ExtractParams(data_object, 1); - auto process_stderr = ExtractParams(data_object, 2); - auto callback = - ExtractParams(data_object, 3); - - // call callback - SPDLOG_DEBUG( - "calling custom callback from caller of cmd {} {}, " - "exit_code: {}", - cmd, joined_argument, exit_code); - callback(exit_code, process_stdout, process_stderr); - }; + Thread::Task::TaskCallback result_callback = [cmd, joined_argument]( + int /*rtn*/, + const DataObjectPtr + &data_object) { + SPDLOG_DEBUG("data object args count of cmd executor result callback: {}", + data_object->GetObjectSize()); + if (!data_object->Check()) { + throw std::runtime_error("invalid data object size"); + } + + auto exit_code = ExtractParams(data_object, 0); + auto process_stdout = ExtractParams(data_object, 1); + auto callback = ExtractParams(data_object, 2); + + // call callback + SPDLOG_DEBUG( + "calling custom callback from caller of cmd {} {}, " + "exit_code: {}", + cmd, joined_argument, exit_code); + callback(exit_code, process_stdout, {}); + }; Thread::Task::TaskRunnable runner = [joined_argument](const DataObjectPtr &data_object) -> int { @@ -140,8 +138,6 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context) std::string process_stdout = cmd_process->readAllStandardOutput().toStdString(); - std::string process_stderr = - cmd_process->readAllStandardError().toStdString(); int exit_code = cmd_process->exitCode(); SPDLOG_DEBUG( @@ -151,15 +147,13 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context) "Exit Code: {}\n" "---- Standard Output ----\n" "{}\n" - "---- Standard Error ----\n" - "{}\n" "===============================", - cmd, joined_argument, exit_code, process_stdout, process_stderr); + cmd, joined_argument, exit_code, process_stdout); cmd_process->close(); cmd_process->deleteLater(); - data_object->Swap({exit_code, process_stdout, process_stderr, callback}); + data_object->Swap({exit_code, process_stdout, callback}); return 0; }; -- cgit v1.2.3