From 1381eb8158516ce0290e08a9c4693812aac8e9f5 Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 13 Dec 2024 18:34:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96exec=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp | 11 ++--------- source/MaaFramework/Task/Component/CommandAction.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp b/source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp index f7ce16587..6b38d8894 100644 --- a/source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp +++ b/source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp @@ -34,16 +34,9 @@ std::optional ProcessArgvGenerator::gen(const string_replace_all_(s, replacement); } - std::filesystem::path abs_path; - if (auto raw_path = MAA_NS::path(res.front()); raw_path.is_absolute()) { - abs_path = raw_path; - } - else { - abs_path = boost::process::search_path(raw_path); - } - + std::filesystem::path abs_path = boost::process::search_path(path(res.front())); if (!std::filesystem::exists(abs_path)) { - LogError << "exec path not exists" << VAR(abs_path); + LogError << "exec path not exists" << VAR(res.front()) << VAR(abs_path); return std::nullopt; } diff --git a/source/MaaFramework/Task/Component/CommandAction.cpp b/source/MaaFramework/Task/Component/CommandAction.cpp index 61da2bfcf..ca4c6c75c 100644 --- a/source/MaaFramework/Task/Component/CommandAction.cpp +++ b/source/MaaFramework/Task/Component/CommandAction.cpp @@ -4,14 +4,16 @@ #include "Utils/Codec.h" #include "Utils/IOStream/BoostIO.hpp" +#include "Utils/ImageIo.h" #include "Utils/Logger.h" #include "Utils/Platform.h" -#include "Utils/ImageIo.h" MAA_TASK_NS_BEGIN CommandAction::~CommandAction() { + LogFunc; + for (const auto& p : cached_images_) { if (!std::filesystem::exists(p)) { continue; @@ -32,7 +34,11 @@ bool CommandAction::run(const MAA_RES_NS::Action::CommandParam& command, const R { "{Box}", std::bind(&CommandAction::gen_box, this, std::placeholders::_1) }, }; - std::filesystem::path exec = path(command.exec); + std::filesystem::path exec = boost::process::search_path(path(command.exec)); + if (!std::filesystem::exists(exec)) { + LogError << "exec not exists" << VAR(command.exec) << VAR(exec); + return false; + } std::vector args; for (const std::string& arg : command.args) {